News for hackers. Stuff that matters.
Re:Swift Functors, Applicatives, and Monads in Pictures by skybrian on Tuesday July 14, 2015 @05:30PM (#9888195)
If functional languages had called them the Mappable, Applicable, and FlatMappable interfaces, and used map(), apply(), and flatMap() instead of operators, it would have avoided a lot of confusion. But I guess that's how you avoid success at all costs.
Re:Swift Functors, Applicatives, and Monads in Pictures by jerf on Tuesday July 14, 2015 @05:58PM (#9888354)
Honest question: Is there a reason 'flatmap' is any better other than it is what you learned it as somewhere?

I'm not convinced English has a word or convenient phrase for "monad", and it doesn't strike me that "flatMap" is it. How do I "flatMap" Haskell's STM monad? Or a probability monad? (I know the mechanics of the answer, I am specifically referring to the English-induced intution.) I don't see the intuition being particularly correct; flatMap is really tied to List, which isn't a particularly great thing to be tied to since it isn't very used. List's monadic interface is cute for some little algorithms, sure, which makes it disproportionately appear in examples, but list's monad implementation has complexity O(m^n) (where m is the size of the lists and n the number of lists you're going to consider) and you need some algorithm that gives you some serious culling on that before it's practical for very much.

Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Tuesday July 14, 2015 @07:24PM (#9888751)
> flatMap is really tied to List

Its tied to collections, not specifically to List. A number of (but certainly not all!) important monads are (or can be viewed as) collections, including Optional/Maybe (which can be viewed as a collection with cardinality restricted to being either 0 or 1.)

Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Tuesday July 14, 2015 @10:26PM (#9889373)
> Its tied to collections, not specifically to List

Actually, it transcends collections in general. As others have noted, the term "flatMap" is the concatenation of "flatten" and "map." There are other containers which support flatMap and satisfy the Monad laws[1]. An example of one in Scala is the Future[2] type. It's flatMap is described as:

  Creates a new future by applying a function
  to the successful result of this future, and
  returns the result of the function as the new
  future.
Conceptually, this behaves similarly to how a flatMap for a collection type behaves. Due to the nature of the Monad laws[1], this similarity is to be expected.

1 - http://eed3si9n.com/learning-scalaz/Monad+laws.html

2 - http://www.scala-lang.org/api/2.11.7/#scala.concurrent.Futur...

Re:Swift Functors, Applicatives, and Monads in Pictures by tel on Tuesday July 14, 2015 @11:40PM (#9889578)
Well that's just it, though. The proper way of generalizing your notion of mapping is Functor and your notion of flattening is Monad. So the intuition behind the word has bought nothing.
Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Wednesday July 15, 2015 @12:37AM (#9889737)
> The proper way of generalizing your notion of mapping is Functor and your notion of flattening is Monad.

You are quite right that the "map part" of flatMap is Functor, as Monads are a model of Functor. IOW, if there exists a Monad for some container, then there also exists a Functor for it.

However, flattening in and of itself does not fully define the flatMap (a.k.a. "bind") part of a Monad. Its atomic use with the map operation is what makes flatMap/bind operations satisfy the expectations of the rules for being a Monad.

Flatten on its own is extremely useful of course. It's often used in definitions of Join type classes.

Re:Swift Functors, Applicatives, and Monads in Pictures by tel on Wednesday July 15, 2015 @02:02AM (#9889934)
It does given a Functor definition. Typically in Category Theoretic presentations Monad is defined as a functor T along with mu and nu, operations that are (a -> T a) and (T (T a) -> T a), 'unit' and 'join'.

The rules for Monad are perfectly well-stated in terms of join—perhaps even better stated if you're one to like Category Theoretic diagram chasing.

Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Wednesday July 15, 2015 @12:56PM (#9892450)
Again, you are quite right. I did not present the other ways to define a conforming Monad and may have mistakenly implied that the unit/flatMap form is "the" way to make one.

For completeness, the forms I am aware of are (in no particular order):

* unit and flatMap

* unit and compose

* unit, map, and join

The valid form which you reference being a model of the last one.

AFAIK, for any container 'T' to be able to satisfy the Monad laws, at least one of the aforementioned three combinators must exist for the container.

Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Wednesday July 15, 2015 @03:10PM (#9893388)
> AFAIK, for any container 'T' to be able to satisfy the Monad laws, at least one of the aforementioned three combinators must exist for the container.

All three of them must, actually, since if one of them exists, all of them do (and you can define the other two in terms of the one you know.)

Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Wednesday July 15, 2015 @02:39PM (#9893180)
"Compose" being Kleisli composition?
Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Wednesday July 15, 2015 @12:21PM (#9892194)
> Actually, it transcends collections in general.

What I mean when I say flatMap is tied to collections is in the same sense that I read the poster to whom I was responding when they said it was tied to list, that is, that the intuition that the name "flatMap" leverages is tied to that construct. Obviously, the operation* it describes is more general, but the farther you get from collections, the less useful the intuition that the name leverages is.

(Whether this is better or worse for comprehension than the Haskell style of naming Monads and other related constructs and their associated operations is endlessly debatable and highly subjective.)

Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Wednesday July 15, 2015 @01:00PM (#9892474)
Gotcha. In reading the post to which you originally replied, it appeared to me that there was an underlying assumption of Monads being specific to collections. My bad.
Re:Swift Functors, Applicatives, and Monads in Pictures by agumonkey on Tuesday July 14, 2015 @09:35PM (#9889226)
Interesting quantification of Option. Mapping Boolean logic to binary arithmetic somehow ?

It's also impressive how much complexity arise from that notion of multiplicity.

Re:Swift Functors, Applicatives, and Monads in Pictures by jbooth on Tuesday July 14, 2015 @10:53PM (#9889457)
Follow-on question, are there any useful monadic constructs not tied to collections (including optional as you said)?
Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Wednesday July 15, 2015 @02:04AM (#9889939)
IO, State, Parsers, and STM are useful monads for which the collection metaphor doesn't seem to be particularly helpful.
Re:Swift Functors, Applicatives, and Monads in Pictures by jbooth on Wednesday July 15, 2015 @11:12AM (#9891679)
STM's a good one. I'd consider I/O and State as solving a self-inflicted problem -- I can have side-effect-creating I/O and State in just plain C with barely any type system.
Re:Swift Functors, Applicatives, and Monads in Pictures by efnx on Wednesday July 15, 2015 @12:56AM (#9889794)
Is Maybe tied to collections? State? Reader? Cont? What about Eff from extensible-effects? I use these every day.
Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Wednesday July 15, 2015 @03:03AM (#9890091)
As mentioned elsewhere here, Maybe is naturally considered a container of zero-or-one elements. The others are good examples, though.
Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Tuesday July 14, 2015 @11:02PM (#9889482)
Parsers is an obvious example.
Re:Swift Functors, Applicatives, and Monads in Pictures by lmm on Wednesday July 15, 2015 @06:34AM (#9890592)
Future, Either, Writer, and Free are the non-collection ones I use most often.
Re:Swift Functors, Applicatives, and Monads in Pictures by tel on Tuesday July 14, 2015 @11:06PM (#9889494)
Silly and wonderful there is always

    data Fake a = Fake
which is trivially a monad

    instance Monad Fake where
      return _ = Fake
      Fake >>= f = Fake
yet it clearly contains nothing.
Re:Swift Functors, Applicatives, and Monads in Pictures by lmm on Wednesday July 15, 2015 @12:03PM (#9892062)
Grandparent asked for useful though :P
Re:Swift Functors, Applicatives, and Monads in Pictures by tel on Wednesday July 15, 2015 @03:39PM (#9893579)
Who says Fake isn't useful? It's very useful for stating that nothing can happen :)
Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Tuesday July 14, 2015 @11:09PM (#9889507)
Futures are another example.
Re:Swift Functors, Applicatives, and Monads in Pictures by jbooth on Wednesday July 15, 2015 @12:06PM (#9892074)
I'd call a Future a threadsafe queue with one element going thru it IMO, it's just as much of a collection as Optional.
Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Wednesday July 15, 2015 @01:28PM (#9892713)
That's the beautiful thing about types which satisfy the Monad laws. Because both Future and Option (in Scala if not other languages) satisfy these laws, I think it perfectly valid to consider a Future to be collection type with a cardinality of 0 or 1 that also abstracts latency.
Re:Swift Functors, Applicatives, and Monads in Pictures by jbooth on Wednesday July 15, 2015 @03:02PM (#9893345)
Yeah, but I can do that without category theory, it's just obvious. I still don't understand what 'monad' offers over 'flatMappable' besides the ability to use 'endofunctor' in the same sentence.
Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Wednesday July 15, 2015 @03:07PM (#9893366)
> I still don't understand what 'monad' offers over 'flatMappable'

Its several characters and syllables shorter, and doesn't appeal to an intuition which is distant from many of the productive uses of construct.

Re:Swift Functors, Applicatives, and Monads in Pictures by mokagio on Tuesday July 14, 2015 @06:22PM (#9888465)
That's true. The concept of "flatmapping" an array is easy to get, but what about flatmapping and optional/maybe value?
Re:Swift Functors, Applicatives, and Monads in Pictures by AdieuToLogic on Tuesday July 14, 2015 @10:37PM (#9889396)
> ... what about flatmapping and optional/maybe value?

The same concepts apply. With an option type, flatMap can be defined in Scala Option[1] types as:

  flatMap[B](f: (A) ⇒ Option[B]): Option[B]
For the empty option situation (None in Scala), the result is a None. For the populated case (Some in Scala), the result is what f produces when given the value contained in the original Option[A] type. Of course, f is free to produce a None for its result should it so desire.

What makes Monads neat IMHO is that so long as the container type adheres to the Monad laws[2], then the developer can fully rely on the behaviour conforming to a common set of expectations.

1 - http://www.scala-lang.org/api/2.11.7/#scala.Option

2 - http://eed3si9n.com/learning-scalaz/Monad+laws.html

Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Wednesday July 15, 2015 @12:13PM (#9892128)
I think the parent was saying that "flatMap" failed to give them intuition around Option, not that Option wasn't a monad.
Re:Swift Functors, Applicatives, and Monads in Pictures by skybrian on Tuesday July 14, 2015 @08:22PM (#9888985)
It certainly doesn't have to be flatmap. But the idea is that someone takes some time to think up an English name and does a bit of user testing to make sense to regular programmers.

This seems to be the approach that Elm is taking. (Although they're reluctant to add monads at all since they take ease of use seriously.)

Re:Swift Functors, Applicatives, and Monads in Pictures by wetmore on Wednesday July 15, 2015 @03:37AM (#9890181)
We all know that naming is one of the hard problems in computer science. Monads in programming have been around for 20+ years now, and you are certainly not the first one to complain about their name. So where are the better alternatives? Surely someone must have come up with a better one by now?

Instead we get nice "English" names which only work for certain monad instances and fail to adequately describe others.

Elm uses "andThen" instead of "bind", which works pretty well for the monadic types in its core library. But you need to start stretching your imagination to see why "andThen" makes sense for other monadic types. Honestly, I'm fine with "andThen", especially in the context of Elm and the monads it implicitly uses. But in the wider world of programming where exotic but useful monad instances exist I'd rather stick to the most general name.

By the way, the more pressing reason for Elm not having monads is the fact that it doesn't have typeclasses (or a similar concept) and doesn't allow you to parametrize over higher-kinded types (like Maybe).

Re:Swift Functors, Applicatives, and Monads in Pictures by gclaramunt on Tuesday July 14, 2015 @10:02PM (#9889306)
What's wrong with 'bind' ?
Re:Swift Functors, Applicatives, and Monads in Pictures by skybrian on Tuesday July 14, 2015 @11:54PM (#9889617)
What's being bound?

Perhaps "then" would work. JavaScript promises use it to good effect, and they're a monad.

Re:Swift Functors, Applicatives, and Monads in Pictures by VladimirGolovin on Wednesday July 15, 2015 @06:43AM (#9890619)
Smaller computations are being bound into a larger computation, where the monad provides the the code that is executed 'between the lines'.

(BTW, my own take on renaming a monad into something less scary is daisychain, or, slightly more to-the-point, chainable.)

Re:Swift Functors, Applicatives, and Monads in Pictures by tel on Friday July 17, 2015 @09:00AM (#9902485)

    (>>=) :: M a -> (a -> M b) -> M b
The `a` is bound in the second argument.
Re:Swift Functors, Applicatives, and Monads in Pictures by mokagio on Tuesday July 14, 2015 @05:38PM (#9888244)
Ahahah, that might be true :) Although because those concepts comes from category theory, i.e. https://en.wikipedia.org/wiki/Functor and there's more to it than just "it defines" map, keeping the "academic" name seems fair enough.
Re:Swift Functors, Applicatives, and Monads in Pictures by jameshart on Tuesday July 14, 2015 @06:43PM (#9888567)
The problem is that the category-theory view of functors and monads and monoids completely dominates the literature.

Imagine if, when you first started programming, and you wanted to do something with numbers, and you found out that in your programming language, the way you did that was to use something they called "Integers" (I know, right? ridiculous). So you google "Integers" and you find https://en.wikipedia.org/wiki/Integer, which helpfully tells you

"In elementary school teaching, integers are often intuitively defined as the disjoint union of the (positive) natural numbers, the singleton set whose only element is zero, and the negations of natural numbers."[1]

And you get the impression that to add a couple of numbers together you're actually going to have to understand cardinality and group theory and so on.

That's kind of where we are with monads, with the insistence on the academic language.

Though it does suggest that I could have fun by persuading beginning programmers that to really grok text processing they need to start off with a thorough grounding in string theory.

[1] I checked with my son, who goes to elementary school. I'm not sure he even knows what a disjoint union is. I'll have to have words with the teacher.

Re:Swift Functors, Applicatives, and Monads in Pictures by TillE on Tuesday July 14, 2015 @08:49PM (#9889075)
I'd forgotten how spectacularly academic Wikipedia's math articles are. It actually seems a little better than it used to be, but for example good luck learning what the hell a quaternion is by reading the Wikipedia article, even if you have sufficient background to understand and use them in practice. The German article is much better.
Re:Swift Functors, Applicatives, and Monads in Pictures by jameshart on Tuesday July 14, 2015 @09:04PM (#9889127)
Right. You don't want to try to learn something mathematical from the Wikipedia article on it - Quaternions are a great example. The trouble with most of the writing about monads is that it's all at the level of the opening paragraph of a Wikipedia math article.

We have to do better at finding a way to teach this stuff.

Re:Swift Functors, Applicatives, and Monads in Pictures by mdup on Wednesday July 15, 2015 @07:55AM (#9890819)
When I started using quaternions for rotations, which -- if we're honest -- is the #1 practical applications, I had much more success building my intuition around this Wikipedia section:

https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotati...

Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Wednesday July 15, 2015 @12:29PM (#9892268)
> The trouble with most of the writing about monads is that it's all at the level of the opening paragraph of a Wikipedia math article.

IME, that's not at all true; most of the theory-heavy sources I've seen are explicitly framed as alternatives to the large body of intuitionist tutorials that avoid theory almost entirely, focusing on a few popular applications (usually, collections and IO.)

Re:Swift Functors, Applicatives, and Monads in Pictures by Ivanov on Tuesday July 14, 2015 @08:57PM (#9889102)
Being able to use something and knowing the whys are two different things. Many people know Calculus(practice), but not many know Real Analysis(theory behind Calculus, the academical bit).

"In mathematics, the quaternions are a number system that extends the complex numbers."

Naturals are a subset of integers. Integers are a subset of rationals. Rational are a subset of reals. Reals are a subset of complex numbers. The latter are a subset of quaternions. It's not difficult to construct each number system. If you look inside any undergrad math textbook, you'll find exact same writing style showcased in the Wikipedia article on quaternions.

Re:Swift Functors, Applicatives, and Monads in Pictures by LimpWristed on Tuesday July 14, 2015 @08:00PM (#9888923)
You're over-exaggerating :) From the wiki link, the very first definition works just fine. In fact, I don't see anything about unions, disjointedness in there. Certainly, no group theory. You don't need to know how to construct, count(cardinality) or know the properties of integers(number/group theory) to know what they are for the purposes of programming. No, there's no cabal making everything more difficult than it needs to be ;D I think wiki always gets unfairly maligned for this sort of thing.
Re:Swift Functors, Applicatives, and Monads in Pictures by corysama on Tuesday July 14, 2015 @06:10PM (#9888411)
Are there any nice, one-step-at-a-time introductions to Haskell that stick to lowly, commonplace English rather than insisting that "just a monoid in the category of endofunctors" is universally preferable because technically it technically is technically more technically correct?
Re:Swift Functors, Applicatives, and Monads in Pictures by chongli on Tuesday July 14, 2015 @06:25PM (#9888484)
I haven't read it but you might want to check out coolsunglasses'[0] book, Haskell Programming from first principles[1]. He wrote it specifically for people who have no background in this stuff.

[0] https://news.ycombinator.com/user?id=coolsunglasses [1] http://haskellbook.com/

Re:Swift Functors, Applicatives, and Monads in Pictures by wetmore on Wednesday July 15, 2015 @03:49AM (#9890209)
Nobody insists "monoid in the category of endofunctors" is universally preferable. It's a joke.

What you'll usually see people insist is to describe monads by their operations, rather than through metaphor. That is, a monad is a type parametrized by some other type, with the following two functions:

1) return :: a -> m a 2) (>>=) :: m a -> (a -> m b) -> m b

such that three laws hold:

a) return x >>= f == f x b) m >>= return == m c) (m >>= f) >>= g == m >>= (\x -> f x >>= g)

For monads in Haskell, this is the technically correct definition.

That said, most people will tell you the best way to understand monads is to look at a few basic monad instance implementations (Maybe, Either a) and program with them, slowly learning new instances.

Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Wednesday July 15, 2015 @12:17PM (#9892154)
Cleaning up the parent's formatting as I think it's too late for them to edit. Content is unchanged:

That is, a monad is a type parametrized by some other type, with the following two functions:

    1) return :: a -> m a
    2) (>>=) :: m a -> (a -> m b) -> m b
such that three laws hold:

    a) return x >>= f == f x
    b) m >>= return == m
    c) (m >>= f) >>= g == m >>= (\x -> f x >>= g)
Re:Swift Functors, Applicatives, and Monads in Pictures by merijnv on Wednesday July 15, 2015 @05:11AM (#9890390)
To be fair, I don't know a single person that explains things using

> "just a monoid in the category of endofunctors"

In fact, even among people who DO know the category theory necessary to understand this expression it's considered a very obtuse and useless explanation. Especially in the context of Haskell.

As for good readable introductions, I consider Wadler's paper "Monads for Functional Programming" to actually be a pretty good introduction. Another good intro is "You Could Have Invented Monads! (And Maybe You Already Have.)" http://blog.sigfpe.com/2006/08/you-could-have-invented-monad...

Re:Swift Functors, Applicatives, and Monads in Pictures by ucarion on Tuesday July 14, 2015 @07:51PM (#9888887)
To add to chongli's suggestion, I learned Haskell (and had a great time doing it) from "Learn You a Haskell": http://learnyouahaskell.com/
Re:Swift Functors, Applicatives, and Monads in Pictures by wyager on Tuesday July 14, 2015 @09:28PM (#9889205)
Those intuitions do not generalize correctly.

It's better for people new to the concepts to realize that they don't understand than to incorrectly believe they understand (based on mediocre collection-oriented analogies).

Re:Swift Functors, Applicatives, and Monads in Pictures by chongli on Tuesday July 14, 2015 @06:13PM (#9888426)
There's more to the interfaces than merely the operators; there are laws, too. Besides that, the operators give a big advantage when sequencing operations, something you can't do with map() notation.
Re:Swift Functors, Applicatives, and Monads in Pictures by jameshart on Tuesday July 14, 2015 @07:29PM (#9888774)
When you implement an equality operator, or addition/multiplication operators on a type there are 'laws' too, but that doesn't stop it coming down to 'has an equals method'.
Re:Swift Functors, Applicatives, and Monads in Pictures by adamwk on Tuesday July 14, 2015 @06:19PM (#9888453)
Then why not have both? Applicative Functors have both `fmap` and `<$>`. `>>=` could easily be an alias of `flatMap` or `bind` or whatever.
Re:Swift Functors, Applicatives, and Monads in Pictures by chongli on Tuesday July 14, 2015 @06:26PM (#9888489)
I'm right there with you. I'm a Haskell user; I love user-definable operators.
Re:Swift Functors, Applicatives, and Monads in Pictures by lmm on Tuesday July 14, 2015 @07:18PM (#9888722)
Because code is read more than it's written; multiple ways of writing the same thing makes it easier to write but harder to read.
Re:Swift Functors, Applicatives, and Monads in Pictures by dragonwriter on Tuesday July 14, 2015 @07:26PM (#9888764)
Multiple ways of writing the same thing makes it easier to read, often, because you are more free to use the form that is more readable and intuitive in context; that's one reason why natural languages (including written languages) tend to have multiple ways of expressing the same ideas.
Re:Swift Functors, Applicatives, and Monads in Pictures by lelf on Wednesday July 15, 2015 @08:20AM (#9890885)
Because 1) those concepts are already have proper names;

2) there is a ton of (even predating our modern programming era) useful literature using proper names;

3) those proposed “non-confusing” names have zero meaning for a lot of monads/applicaties/… I feel like 99% who want whem have only seen containers.

Re:Swift Functors, Applicatives, and Monads in Pictures by whateveracct on Tuesday July 14, 2015 @05:59PM (#9888362)
Joinable would be a much better name than FlatMappable. FlatMap makes it apply too much to collections.
Re:Swift Functors, Applicatives, and Monads in Pictures by quchen on Tuesday July 14, 2015 @06:04PM (#9888384)
"flatmap" hints at it consisting of two components, flattening and mapping. Both are to be seen in a generalized context though, and the words are familiar to many when thinking about collections.

1. Mapping - the same as what Functor/Mappable provides. We use this to "map" over a structure, producing a nested structure.

2. Flattening: we just built our nested structure, time to squash it again.

In types akin to templates,

    Structure<A>
    ------------------------ (map something suitable over it)
    Structure<Structure<B>>
    ------------------------ (flatten it)
    Structure<B>
It's not a terrible name, but it probably doesn't help seeing the bigger picture either. "Flattening" a parser, a subroutine, an empty thing -- that's not really something very intuitive.
Re:Swift Functors, Applicatives, and Monads in Pictures by Tyr42 on Wednesday July 15, 2015 @09:14AM (#9891053)
Join (flatten) is a fundamental monadic operation.

    join:: m (m a) -> m a
I have a parser of a single character and a way to generate new character parsers

char :: Char -> Parser Char x :: (Parser Char) let y = fmap (char . toUpper) x :: (Parser (Parser Char))

It's a parser which creates a new parser out of the input it consumes.

I do think that fmap/pure/join is the easier to understand set of defining functions for monads.

Re:Swift Functors, Applicatives, and Monads in Pictures by quchen on Wednesday July 15, 2015 @02:07PM (#9892991)
join is one possible fundamental monadic operation. You can also define monads in other ways, such as endofunctors such that the Kleisli structure forms a category. In this case, you have the identity arrow (called return in Haskell) and Kleisli composition (<=< in Haskell) as fundamental operations. Neither of these is more fundamental than the other. You can convert back and forth,

    f >=> g = \x -> f x >>= g
    m >>= f = (f <=< id) m
    
    join = (>>= id)
    m >>= f = join (fmap f m)
So if you're focused on composing monadic operations, thinking about it in terms of >=> is often a good idea.
Re:Swift Functors, Applicatives, and Monads in Pictures by dllthomas on Wednesday July 15, 2015 @12:09PM (#9892101)
One thing that I really like about Haskell's practice of naming interfaces after mathematical constructs is that it makes it clear what the rules for those interfaces "should be" and changes the character of a few kinds of discussion.

If we called them "Mappable", "Applicable", "FlatMappable" (yuck), "AssociativeAppendableWithIdentity"... then there would be disagreement about whether some new construct "is really" Applicable. Is summation really "Appending"?

And these arguments are high stakes, because the most important thing about an interface is that it tells the user what they can expect. If I ask for an Appendable, and get something that doesn't follow the rules I think Appendable should have, then... whose code is broken?

In Haskell, it's entirely clear whether a new type "is really" a Monoid or Functor - does it obey the laws? Okay!

Whether "container" is a good way to think of Functor is recognized as a purely pedagogic question (not that there's never drama in pedagogy, but those people getting work done can opt out without worry that it will break their code when they try to interface with others).

Re:Swift Functors, Applicatives, and Monads in Pictures by dustingetz on Tuesday July 14, 2015 @05:49PM (#9888304)
I don't think applicable is the same as apply, am I wrong?
Re:Swift Functors, Applicatives, and Monads in Pictures by jfoutz on Tuesday July 14, 2015 @06:01PM (#9888374)
eh, it's close. if the semantics are

    apply(fun,args)
it's not much of a mental stretch to do

    apply([fun1,fun2], [arg_for_fun1,arg_for_fun2])
it's probably better to just suck it up and learn the precise terms though. a lot of hazy thinking can hide behind overloaded words.