3 ms·
Okay, let’s make concrete what I said about fmap. Let’s say we have a function addOne. Then > fmap addOne Nothing Nothing > fmap addOne (Just 2) Just 3 >
by moomin 8y ago
Okay, let’s make concrete what I said about fmap.
Let’s say we have a function addOne. Then
> fmap addOne Nothing
Nothing
> fmap addOne (Just 2)
Just 3
> fmap addOne [1,2,3]
[2,3,4]
> fmap addOne parseInt
(A function that reads a string for an int and adds one to the result.)
So fmap is polymorphic over a whole bunch of things that are unrelated in most other languages. (You might be asking why it’s called fmap and not map, and I wouldn’t have a good answer for you.) So, the abstractions of “Nullable, List and Function Return Value” are all part of a more general abstraction, Functor.
Now, at this point some people try to look up what a category theoretic definition of a Functor is. That’s fine, more power to their elbow. However, really all a Functor is in a practical sense for a dumb programmer like me is _something that supports
fmap_.
My point is, it’s this stuff that’s useful and cool in Haskell. It won’t help you understand whatever they’re talking about on r/Haskell. And my only point about Kliesi categories is that you don’t need to know what they are. There’s a million and one interesting computer science concepts that are usable with a type system with Haskell’s properties, but you don’t have to use them all.
- stcredzero 8y agoThanks. However your comment is still unintentionally enigmatic and emblematic!
- moomin 8y agoNone of us are perfect. :)
- stcredzero 8y agoIt's the coding scenes that do a good job on PR that win. "Amateurs study tactics, while professionals study logistics." -- I think there's something analogous with programming languages and ecosystems/communities.