News for hackers. Stuff that matters.
Re:Functors, Applicatives, and Monads in Pictures (2013) by Zababa on Thursday October 21, 2021 @06:15AM (#28942476)
I wish people would say map instead of fmap, as fmap is Haskell-specific, and map exists in lots of other languages.
Re:Functors, Applicatives, and Monads in Pictures (2013) by cabalamat on Thursday October 21, 2021 @07:45AM (#28943068)
If the examples are in Haskell, it should definitely use the Haskell term, so that people can then run the code.

An alternate might be to have examples in multiple languages, colour-coded.

Re:Functors, Applicatives, and Monads in Pictures (2013) by Zababa on Thursday October 21, 2021 @09:08AM (#28943830)
I think they should use map in the text and fmap in the Haskell examples, while explaining quickly why Haskell uses fmap. You can translate an example with map in Python, JS, Java, etc. fmap is Haskell-specific. I also think we shouldn't tie "functional design patterns" to Haskell so much, but that's a bigger issue.
Re:Functors, Applicatives, and Monads in Pictures (2013) by wlamartin on Thursday October 21, 2021 @06:32AM (#28942581)
Seems like this would be a bit confusing though? `fmap` (flatMap) corresponds to `bind` or `chain` (Monad) rather than `map` (Functor) right?
Re:Functors, Applicatives, and Monads in Pictures (2013) by pwm on Thursday October 21, 2021 @06:51AM (#28942701)
Nope, `fmap` is indeed short for functor map. It's a historical accident in Haskell as `map` was specialised for lists (ie. `[]`) from the start and later, when mapping would be generalised to all things Functorial, it needed a new name so as to not break everything, hence `fmap`.
Re:Functors, Applicatives, and Monads in Pictures (2013) by wlamartin on Thursday October 21, 2021 @07:26AM (#28942924)
Awesome thank you for the clarification. I extra agree with the confusion then since `fmap` sounded exactly like `flatMap` to me!
Re:Functors, Applicatives, and Monads in Pictures (2013) by Twisol on Thursday October 21, 2021 @06:51AM (#28942709)
No, "fmap" is actually the name in Haskell given to the function defined by the Functor typeclass. It was named "fmap" ("f"unctor map) because "map" was already taken by the map specialized to lists.
Re:Functors, Applicatives, and Monads in Pictures (2013) by sfvisser on Thursday October 21, 2021 @10:18AM (#28944787)
`flatMap` is actually called `concatMap` in Haskell, or more generically the monadic bind operator `>>=`.