News for hackers. Stuff that matters.
Re:Fantasy Land 1.0 by wrong_variable on Wednesday September 14, 2016 @07:17PM (#12502027)
James Forbes has an amazing article explaining Fantasy Land.

https://james-forbes.com/?/posts/the-perfect-api

Re:Fantasy Land 1.0 by nchelluri on Wednesday September 14, 2016 @08:48PM (#12502558)
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.

Re:Fantasy Land 1.0 by keithnz on Wednesday September 14, 2016 @09:57PM (#12502797)
maybe you might want to start here :- https://drboolean.gitbooks.io/mostly-adequate-guide/content/

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

Re:Fantasy Land 1.0 by nchelluri on Wednesday September 14, 2016 @10:23PM (#12502872)
Looks interesting, thank you for the link. I've already dived in to the first chapter.
Re:Fantasy Land 1.0 by danidiaz on Thursday September 15, 2016 @02:57AM (#12503977)
I think one benefit is facilitating "getting to grips" with new code, much like design patterns in a way. Of course, this requires familiarity. If someone tells you something is a "monoid", you instantly know that the somethings can be combined in an associative way, and that there is a "neutral" something that can always be constructed without arguments.

Another benefit is that these abstractions appear again and again under many contexts. Recognizing them allows you to give them a common interface, instead of flatMap for lists, andThen for promises, and so on.

Re:Fantasy Land 1.0 by recursive on Wednesday September 14, 2016 @08:14PM (#12502408)
I'm one of the unwashed masses that probably just doesn't see the Point, but I'm confused why claims like this are made.

> the last API you'll ever need

So like... if I wanted to make a post to twitter, I'm pretty sure I'd need another API.

Re:Fantasy Land 1.0 by daneel on Wednesday September 14, 2016 @09:01PM (#12502595)
API in this case refers to it's original meaning, that is, the interface that is available on a specific "class" of objects. Here, the "class" of objects are mimicking haskell like typeclasses.

The chart on the fantasy-land github page demonstrates the interfaces available on each typeclass. For instance, a Maybe is a functor, so it has the map interface. It's also a Monad so it has the chain interface.

Unfortunately, API is a loaded term and I think the author doesn't do a good job differentiating from the common usage of the term.

Re:Fantasy Land 1.0 by recursive on Thursday September 15, 2016 @01:54PM (#12508277)
Even in that meaning, it still doesn't make sense. Say there was an abstracted twitter standard defined in an RFC, and a library was provided for interacting with it. There is no Twitter(tm), just implementations of the twitter RFC.

Even then, I need to know what the names of the properties are that I have to provide to the fantasy-land-compliant-whatever. Being an expert in fantasy land doesn't tell me that "message" is the property that contains the body of the twitter-compliant message. I still need an api.

Re:Fantasy Land 1.0 by cjhveal on Wednesday September 14, 2016 @09:04PM (#12502604)
A programatic interface can be exposed via functions over data structures, methods on objects, or HTTP requests against a server's endpoints, to name a few examples.

I think the confusion here arises from a fairly common conflation of a web service with the interface used to interact with said service.

Re:Fantasy Land 1.0 by recursive on Thursday September 15, 2016 @10:58AM (#12506685)
In that case, it seems like a fairly empty claim. Here's another "last API you'll ever need".

    value["functionName"](...[arguments])
value is the the thing you're operating on. functionName is the name of the thing you want to do. arguments are any other relevant values.