Looks really great!
By the way, what tool do you use to write such pretty illustrations/pictures ?
Thank you! I did them with a fountain pen and then colored them in Pixelmator (Gimp would work just fine too).
pixelmator is the best photo app ever
+1 - love the pictures - LYAH style :D
+1 I like the Dexter's part :)
Insane! I love it!
I've often found that people say, "why the box?" The answer is laziness, which really gets at the heart of Haskell, period. Unfortunately, I've found the hardest part about learning monads (not as true with applicative functors) is learning about all the individual monad *instances*. E.g., how `Cont`, `Reader`, or `State` work. Monads just give you a way to chain things together, to actually understand individual instances of monads, you have to scratch your head a little and draw out some examples.
I'm loving this! Well done. =)
Great Job! Now do this for arrows! :)
Really, really great!
Excellent article! I learnt a lot from this. I believe you have a mistake here:
the Maybe data type defines two related contexts:
Instead of the above, it should be as
the Maybe a data type defines two related contexts:
This is because Maybe is a type constructor and not a type. However, Maybe a is a concrete data type.
You are technically correct, but in casual speech I've seen `Maybe` used to mean `Maybe a`. I would rather not complicate the issue unnecessarily for beginners.
Just one thing left bothering me. At the start you describe a Functor as a type. Then you start implying they are functions by saying they can be applied. Can someone clarify, what is "Functor" supposed to refer to when used as a noun?
Functor is a typeclass in Haskell. This means that any data type that defines the functions in that typeclass, is a functor. Here's the definition of the typeclass:
class Functor f where
fmap :: (a -> b) -> f a -> f b
So, any data type that adds an instance for Functor is now a functor. For example, here's the definition for lists:
instance Functor  where
fmap = map
So lists are functors. Similarly, here's the definition for functions:
instance Functor ((->) r) where
fmap f g = (\x -> f (g x))
So functions are functors too. So basically, functor as a noun = any data type that works with fmap.
ok I think I understand but the final definition you gave in the article doesn't sit that well with me.
functors apply a function to a wrapped value using
Could it better be phrased:
a Functor is boxed data which can be transformed using
Oh you're right, my wording is bad there. Look at the edit I made, that's how I meant to write it.
It helps but still doesn't really leave with a clear picture in my head of a "Functor". The way your phrasing it now makes it sound like it could be the concept of transforming a wrapped value using
fmap though other parts of the article made me think of it as data matching a certain pattern (within a box).
"a Functor is any data type that works with fmap" like you said in your previous comment is nice and clear for me.
perhaps more simply I could just say I would like to be able to think of a "Functor" as data matching a certain pattern while the way you define it at the end of the article makes it sound like I could be missing something.
I want to end the article by talking about how to use functors and applicatives, not what they are. But I added a bit in the section on functors that should help.
Ok personally I think you should reiterate the definition along with how they are used in the conclusion. Another thing that made me feel I was missing something about Functors is when you talk about monads you say they return "a wrapped value" instead of just saying they return "a Functor". would it not be correct to call them Functors?
Ah, that's a good point. When a function returns a `Just 1`, `Just 1` is a monad. But to be a monad a value also needs to be an applicative. And to be an applicative a value also needs to be a functor. So if `Just 1` is a monad, it is also an applicative and a functor. I could be more clear about this, I'll edit the post.
I think it could be interesting to release this article as a github repo so people can tweak it to perfection. https://github.com/substack/st... did this with node streams. Its about time we had a canonical monad explanation and this is the closest I've come to getting them!
That was great. I'm not even a Haskell-er but found this a fun explanation of Monads.
Nice explanation! I am currently learning about functors and applicatives. Your explanation has helped shine a light on these areas and made them easier to understand.
wow - no donate or buy me a coffee link. I feel like I've stolen from you. Absolutely fantastic way of explaining the essence of monads.
Really great. I want more!
Thanks, this cleared up some gaps in my knowledge after reading LYAH. This should be standard additional reading for slow readers of that book.
Thanks. Good job.
Great guide and great pictures!
Then why is this wrapper neccessary?
Great article !!