Comments (12)
Certainly appears that its Fantasy Land deviating in terminology: http://en.wikipedia.org/wiki/Monad_(functional_programming)
from fantasy-land.
I believe the Fantasy Land terminology is meant to be more approachable to the lay programmer, and adapt it to a more natural style in Javascript. of
and chain
are more suggestive than return
and bind
, especially considering those words are already used for separate concepts.
Option
and Maybe
is more of a toss-up. Both are in use elsewhere though; for example, Scala uses Option
.
from fantasy-land.
Option and Maybe is more of a toss-up. Both are in use elsewhere though; for example, Scala uses Option.
Yeah, I see. But still, Maybe
is the term I've seen used more at least in the javascript community.
I believe the Fantasy Land terminology is meant to be more approachable to the lay programmer, and adapt it to a more natural style in Javascript.
The of
/chain
"naturalizations" are for a non-audience, and are to the the detriment of your actual potential community, this I have no doubt.
Firstly what is a "lay programmer" insofar as what concepts fall in and out of that umbrella? Second, this spec covers topics that are far from the the lay programmer of the javascript community wherein by that I mean examining the code in packages across npm
and bower
and component
etc surely demonstrate that the entire foundation of Fantasy Land is far-and-away different than the typical JavaScript
programming. Thus, I find it odd to say the least that of
and chain
is where the "naturalization" starts.
Further, its actually counter-intuitive. JavaScript programmers that are actually taking the time to study functional paradigms, and maybe its mathematical foundations (Category theory in particular), etc. are just going to be confused and turned off by this spec if of
and chain
are any indication.
http://www.youtube.com/watch?v=dkZFtimgAcM
http://modernjavascript.blogspot.ca/2013/06/monads-in-plain-javascript.html
http://functionaljavascript.blogspot.ca/2013/03/implementing-monads-in-javascript.html
http://stackoverflow.com/questions/8656172/monads-in-javascript
http://igstan.ro/posts/2011-05-02-understanding-monads-with-javascript.html which is referenced by @fogus, the author of http://blog.fogus.me/2013/03/20/fun-js/
etc
If there is concern over the fact that JavaScript
has already labeled bind
in the Function.prototype.bind
I think its an acceptable tragedy. It seems to me that Function.prototype.bind
is only useful for assigning this
context which shouldn't matter when working functionally as this
simply stands to make life harder in every way for functional style. Once you remove this
as a feature (Lint it away, etc) Function.prototype.bind
can cease to exist and we can move on with functional life.
from fantasy-land.
Well, I may have thrown out the "lay programmer" label a bit casually. I apologize for that - let me try to explain myself better.
Personally, I like the Fantasy Land naming because it aligns more naturally with how I've internalized Monads. I believe that "chaining" is a fairly intuitive action, and can be readily comprehended without much fanfare. of
is likewise a glorified constructor. Of course monads have a wealth of mathematical structure to them, but at times when I'm using them in a practical setting, I think of them in terms of what they can do for me. I suspect many programmers act similarly. So I find it a big plus to have the terminology and intuition align.
Yeah, I see. But still, Maybe is the term I've seen used much more, including in the javascript community.
I prefer Maybe
in this instance, but I think the ship may have sailed on that one.
from fantasy-land.
I think we're having two separate conversations. You're talking about what works for you personally, in isolation, and I'm trying to talk about what works in the context of most anyone else who is learning and using functional programming. Had Fantasy Land invented Monad's they would be free to codify the terminology, but that is not the case.
from fantasy-land.
Anyhow bind
and unit
are intuitive too. unit
for instance is about bringing values into the fold, .e.g:
cm.unit(5) -> 5cm
from fantasy-land.
Yeah, I see. But still, Maybe is the term I've seen used much more, including in the javascript community.
I prefer Maybe in this instance, but I think the ship may have sailed on that one.
I do wonder about the collision of HTMLOptionElement via the Option shortcut in the browser side in terms of code & conceptually for javascript programmers. Although it becomes moot point when you use modules and you can do this (but this ends up with a mix of both Maybe
and Option
), but is this worse...?
var Maybe = require('fantasy-options');
Maybe.Some(1);
I personally don't mind renaming Option
to Maybe
including the constructors, but like @Twisol pointed out, the ship might have sailed?
from fantasy-land.
A monad has been known as:
- Triple
- Command
- Computation expression
The of
transformation has been known as:
- Return
- Point
- Pure
- Unit
- Singleton
The chain
transformation has been known as:
- Bind
-
=
- FlatMap
- SelectMany
Anyway, names:
'Tis but thy name that is my enemy;
Thou art thyself, though not a Montague.
What's Montague? it is nor hand, nor foot,
Nor arm, nor face, nor any other part
Belonging to a man. O, be some other name!
What's in a name? that which we call a rose
By any other name would smell as sweet;
So Romeo would, were he not Romeo call'd,
Retain that dear perfection which he owes
Without that title. Romeo, doff thy name,
And for that name which is no part of thee
Take all myself.
from fantasy-land.
Bikeshedding a bit. If only the documentation clearly states that of == return and chain == bind, then Haskellers should have no problem. I think this needs to go into the documentation to avoid confusion.
Another thing is that for example lodash is using "redirects" in their documentation to make it easy for people who are used to different names.
Overloading bind in javascript seems like an extremely bad idea.
from fantasy-land.
We accept pull requests ;-)
from fantasy-land.
Closing this, as it's seems to be resolved.
Provide feedback otherwise :-)
from fantasy-land.
Cheers
from fantasy-land.
Related Issues (20)
- [Question] Type signature for ap HOT 2
- Adding Folktale to implementations.md
- Equivalent for Serial typeclass? HOT 1
- Is really necessary specify "No parts of <...> value should be checked"? HOT 11
- Add Traversable1 HOT 3
- Help understanding use of identity in Traversable laws HOT 2
- Fantasy Land specification version number HOT 1
- Switch to Symbols HOT 2
- Wrong argument in Traversable HOT 4
- Is monet.js compatible? HOT 1
- Why FL specifies the ChainRec typeclass when there is the trampoline monad? HOT 7
- What does "and" mean? HOT 2
- Can someone explain me how I should understand Semigroup? HOT 5
- Remove all OOP features HOT 21
- Traversable and Foldable use multiple variables as arguments HOT 12
- Profunctor should require Contravariant HOT 10
- Implementation of `Compose` is confusing HOT 3
- should Chain properties depends on fantasy-land/ap (and possibly .map)? HOT 4
- Why putting "fantasy-land/" before everything in readme? HOT 3
- Is `Pair` a valid instance of `MonadRec`?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fantasy-land.