mostly-adequate-guide
mostly-adequate-guide copied to clipboard
Ap implementations, up to day with "fantasy-land"?
Hello,
I'm a beginning student of FP, following this book. I'm very thankful for this resource. I've noted discrepancies. I am wondering if the information in the book is up-to-date?
Is the order for ap
all consistent between here
https://github.com/fantasyland/fantasy-land/issues/283#issuecomment-362183754
here
https://mostly-adequate.gitbooks.io/mostly-adequate-guide/ch10.html#applying-applicatives
here
https://github.com/DrBoolean/immutable-ext
...etc all the same or has there been a change? From what I've gathered, Fantasy-Land is often reference as the guideline. So, would the Applicative Functor in this book pass, say, this test
https://github.com/sanctuary-js/sanctuary-type-classes#applicative--typeclass
Which seems to be following that guide?
Hi, great to hear that :) And... hmmm... I guess that you're right (and thanks for pointing that out!).
Let's consider the object target as the first argument of a function.
We currently define our Applicative
s as pointed Functor
s with
ap :: Apply f => f (a -> b) -> f a -> f b
whereas, fantasyland currently define Applicative
s as pointed Functor
s with
ap :: Apply f => f a -> f (a -> b) -> f b
There might be discrepancies in some other places as well. I'll have to check.
fantasyland is the closest thing there's to a standard of algebraic structures in the JavaScript. I'd definitely work towards having the book implementing fantasyland's specifications.
What do you think @DrBoolean ?
Hi! Yeah, i’m Aware of the difference and decided to stick with what every other do language does. I don’t know why fantasyland decided to change the spec, but I dislike it personally.
I agree that conforming to the JS spec is valuable, but i’d rather leave the book language agnostic (using js as a teaching tool).
I think the best solution is to point out the difference with a warning or something.
I'll still look a bit more closely at the specs, if it's just about changing one type signature by inverting two arguments, I'd rather give it a shot.
Even as a learning material, being able to point out some standard is good for people that want to go beyond. I am not sure how far we currently are from the fantasy-land specs, perhaps already quite close. If not, I believe a note somewhere in the appendix or the introduction is indeed a good idea.
I'm down with writing something like "this diverges from the fantasyland spec, but matches every other spec out there", then maybe give an example of the fantasyland version and why they might be different. Maybe in an "info" block or something.
I think the goal and focus of the book is to enable people to program in any (ML-ish) functional language rather than be a definitive guide on how to do it in JavaScript.
I do agree with the goal. From what you're saying, fantasyland seems to have quite a singular API, let's stick to the warning / disclaimer then.
:+1: will do.