
Fantasy Land 1.0 - porsager
https://github.com/fantasyland/fantasy-land/releases/tag/1.0.0
======
sotojuan
Fantasy Land is a great project—proof of how extensible JavaScript can be.
There are some very interesting related projects:

[https://github.com/Avaq/Fluture](https://github.com/Avaq/Fluture) is
basically lazy and better promises. A+ spec got nothing on this.

[https://github.com/sanctuary-js/sanctuary](https://github.com/sanctuary-
js/sanctuary) adds better typechecks, combinators, and types like Maybe.

[https://github.com/origamitower/folktale](https://github.com/origamitower/folktale)
An upcoming collection of similar tools for JavaScript.

And of course, there's Ramda.

I think these libraries may sound impossible to use at work at first, but if
you play with them for fun, you can at least learn some cool techniques or
paradigms.

~~~
spion
> lazy and better promises. A+ spec got nothing on this

Better how? Does it for example support unbounded recursion without stack
overflow?

    
    
      function f(n) {
        if (n > 0) return Promise.resolve(n - 1).then(f)
      }
    

Because promises do (there is no maximum n above)

Also at a quick glance I see the following:

> Be careful when cancelling a hooked Future. If the resource was acquired but
> not yet consumed, it will no longer be disposed

This works in Bluebird; the resource will be disposed even if the promise is
cancelled.

~~~
wrong_variable
Promises are Eagar - it means it has the advantages of Eagerness.

Being Lazy has the advantages of laziness which is that if you do not clean
your room, you became a hoarder and your room overflows.

The point I am making is that either of these tools are not holy grail. I do
not think a solution for all is going to exist, just use them when it best
suits the application - I think ( Like its just my dumb opinion )

also @spion I think we are going to take this argument to our death beds :D

~~~
sotojuan
Agreed and I probably shouldn't have said native promises are bad. I think
they're okay—flutures just work better with me and how I program.

------
grayrest
If you're interested in fantasy land, you might also be interested in:

[https://github.com/rpominov/static-land](https://github.com/rpominov/static-
land)

[https://github.com/gcanti/flow-static-land](https://github.com/gcanti/flow-
static-land)

------
frio
Javascript is in somewhat of a weird neverland currently. I really want to use
this style of library -- mori, Ramda and others are extremely tempting, and
fantasy-land (/static-land, which is more up my alley) are doing great work.

... but, all these libraries are huge. I feel guilty foisting hundreds of
kilobytes of JS on my users, just so I can write code that I feel is slightly
more elegant. I'm avidly waiting for tree-shaking/jsnext:main to truly take
hold, and make these tools more practical.

Gripes aside, congratulations to the Fantasy Land team :).

~~~
girvo
Leverage Rollup's "tree-shaking" optimisation along with ES6 modules ("import
{ Maybe } from 'ramda-fantasy'") and you'll only be adding what features you
actually use.

Combine it with a decent transpiler (I recommend Bublé) and Uglify and you're
off to the races: tiny builds, that work wonderfully.

~~~
frio
Yep! As I mentioned, I agree that this is the future :). We're just not
_quite_ there yet (mainly because lots of libraries still don't ship
`jsnext:main` entries, and plenty of downstream libraries end up doing an
`import _ from 'lodash'` or similar).

~~~
girvo
Totally agreed. I'm definitely looking forward to it though, that's for
certain! Rollup still has a little ways to go, as does the ecosystem in
general, but I'm optimistic for sure!

------
BatFastard
The link say absolutely nothing about what the project is.

~~~
wrong_variable
James Forbes has an amazing article explaining Fantasy Land.

[https://james-forbes.com/?/posts/the-perfect-api](https://james-
forbes.com/?/posts/the-perfect-api)

~~~
nchelluri
I've gotta be honest, I've read about half of this so far and I'm not quite
sure what I'm looking at.

Every object conforms to an interface, including some error handling
functions. The interface is about composition and transformation and
iteration/operation (map).

Is this about functional programming? It seems like it must, but I know very
little about that and still have no real idea what the benefit of this is or
even its purpose.

Edit: So I see that these are algebraic properties that are being defined, to
relate it to my limited knowledge I see that Setoid define an equivalence
relation interface, equals, which your objects must conform to.

My next question is what is the benefit of programming like this? Maybe I'd
have to brush up on my algebra and learn how these
relationships/"specifications" are useful.

I am actually kinda curious about this, but it's a little hard to penetrate.

~~~
keithnz
maybe you might want to start here :- [https://drboolean.gitbooks.io/mostly-
adequate-guide/content/](https://drboolean.gitbooks.io/mostly-adequate-
guide/content/)

around ch9 ( [https://drboolean.gitbooks.io/mostly-adequate-
guide/content/...](https://drboolean.gitbooks.io/mostly-adequate-
guide/content/ch9.html) ) they start mentioning fantasy-land and you should
also have a good background in what FL is trying to achieve.

~~~
nchelluri
Looks interesting, thank you for the link. I've already dived in to the first
chapter.

------
mmastrac
The main page [1] gives some info about the project and might be a better
link: "Specification for interoperability of common algebraic structures in
JavaScript"

[1] [https://github.com/fantasyland/fantasy-
land](https://github.com/fantasyland/fantasy-land)

------
jestar_jokin
Now I just some way to use it with TypeScript! Unfortunately, it seems support
for Higher Kindred Types is lacking. Apparently you can use some neat trick to
kinda fake HKTs in Flow, but not in TypeScript, due to its lack of nominal
typing. (I don't know the details, though.)

------
pschastain
So what exactly is it? No explanation on Github. Based on the first comment
here it seems to be a javascript library of some kind, but nothing on what it
does or should be used for.

~~~
dr_zoidberg
From the README.md on GitHub:

> (aka "Algebraic JavaScript Specification")

It's a JS library to implement algebras in code. And:

> An algebra is a set of values, a set of operators that it is closed under
> and some laws it must obey.

> Each Fantasy Land algebra is a separate specification. An algebra may have
> dependencies on other algebras which must be implemented.

So that is it. It's "weird", it has a lot of functional concepts (which may or
may not be present already in the language -- I'm not a JS-guy myself). It
sure must be interesting working on code that does all the things this project
does, and I can see it must've required it's share of effort.

~~~
pschastain
Where did you find the "README.md"? The op link has 5 bullet points from the
v1.0.0 release notes and a "thanks to..."

~~~
dr_zoidberg
Go to the project page[0] on GitHub and the first thing it loads is the
README.md file.

[0] [https://github.com/fantasyland/fantasy-
land](https://github.com/fantasyland/fantasy-land)

------
qwertyuiop924
Nice project. Of course, when I think Fantasy Land, I think of this:

[https://youtube.com/watch?list=PLMs_JcuNozJa7tg80N_kITisZjHH...](https://youtube.com/watch?list=PLMs_JcuNozJa7tg80N_kITisZjHHeE3uo&v=GpjgvANB5mY)

There's something _wrong_ with me.

------
ilostmykeys
Haskel Land is a more apt name, don't you think?

