3 ms·
Actually, monads are pretty easy to understand, but learning to use them is harder. Imagine two functions : A -> k B B -> k C Can you turn those into A -> k
by moomin 10y ago
Actually, monads are pretty easy to understand, but learning to use them is harder.
Imagine two functions :
A -> k B
B -> k C
Can you turn those into
A -> k C
Such that you can just think of it as functional composition? If you can, k is a monad.
The catch is, knowing what a Monad is is a bit like knowing what a saxophone is... the real problem is learning how to play it.
- edem 10y agoCool. What does `k` stand for? A function?
- moomin 10y agoA higher-level type (which is a function, if you allow functions in your type system). Examples: List of a One or zero of a A randomly chosen a A function that takes an s and returns an a and another s i.e. s -> (s, a) aka "a stateful computation returning a) A routine that reads a file and returns an a. In each case, the point is that you can a) write code that acts as if the k isn't there and hence b) re-use code between all of these things without changing it. I'm going to take the opportunity to recommend http://www.cis.upenn.edu/~cis194/spring13/ http://www.cis.upenn.edu/~cis194/spring13/. Do all of the exercises, even the really basic ones. What you learn by the end will blow your mind.
- edem 10y agoThanks, I'll try it out! Is it applicable for someone with zero Haskell experience? Am I supposed to join a class which starts somewhen or how this site works?
- moomin 10y agoIt's literally just Brent Yorgey's lecture notes. Read the notes for week 1, do the exercises, repeat. I learned Haskell from scratch using it. Use stack and a random text editor. What it won't do is make you fluent in modern Haskell. That would be a much longer course. However, I guarantee that if you work through it you will have some great "Wow" moments.
- edem 10y agoThanks! It is on my todo list now!