3 ms·
I wish people would say map instead of fmap, as fmap is Haskell-specific, and map exists in lots of other languages.
by Zababa 5y ago
I wish people would say map instead of fmap, as fmap is Haskell-specific, and map exists in lots of other languages.
- wlamartin 5y agoSeems like this would be a bit confusing though? `fmap` (flatMap) corresponds to `bind` or `chain` (Monad) rather than `map` (Functor) right?
- Twisol 5y agoNo, "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.
- pwm 5y agoNope, `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`.
- wlamartin 5y agoAwesome thank you for the clarification. I extra agree with the confusion then since `fmap` sounded exactly like `flatMap` to me!
- sfvisser 5y ago`flatMap` is actually called `concatMap` in Haskell, or more generically the monadic bind operator `>>=`.
- cabalamat 5y agoIf 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.
- Zababa 5y agoI 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.