Understand Functor, Applicative and Monad
Functor
- A Functoris any data type that defines howfmapapplies to it.
- Lists are functors too!
- Functions are Functors too. When you use fmap on a function, you're just doing function composition!
- Functors apply a function to a wrapped value
Applicatives
- Applicatives take it to the next level. With an applicative, our values are wrapped in a context.
- Applicativepushes- Functoraside.
- Control.Applicativedefines- <*>
- Applicatives apply a wrapped function to a wrapped value
Monads
- Monads apply a function that returns a wrapped value to a wrapped value.
- Monads have a function >>=(pronounced "bind") to do this.
- Monadis another typeclass.
- Maybeis a- Functor, an- Applicative, and a- Monad
- Haskell also provides us with some syntactical sugar for monads, called donotation
Conclusion
- Functor,- Applicative,- Monadare typeclass, the value implements them is one- Functoror- Applicativeor- Monad
- A functor is a data type that implements the Functortypeclass.
- An applicative is a data type that implements the Applicativetypeclass.
- A monad is a data type that implements the Monadtypeclass.
- A Maybeimplements all three, so it is a functor, an applicative, and a monad.
- syntax sugar
- functors: you apply a function to a wrapped value using fmapor<$>
- applicatives: you apply a wrapped function to a wrapped value using <*>orliftA
- monads: you apply a function that returns a wrapped value, to a wrapped value using >>=orliftM
 
- functors: you apply a function to a wrapped value using 
# normal
f a -> b
# functor: <a>
f <a> -> <b>
# applicative: <b>
<f> <a> -> <b>
# monad: f a -> <b>
<a> (f a -> <b>) -> <b>
所以
- functor 解包参数
- applicative 解包函数
- monad 把一个既不是normal也不是functor情形的函数和一个包裹参数颠倒顺序
另外一种视角
- Functor: apply a function to a container.
- Applicative: apply a multi-argument function to multiple containers.
- Monad: like- Applicativebut I can decide what to do next after each step.
所以可以把这个 container 看作“更多数量的元素”,把monad看做可中断的流水线。

Congratulations @weaming! You have completed the following achievement on Steemit and have been rewarded with new badge(s) :
Click on the badge to view your Board of Honor.
If you no longer want to receive notifications, reply to this comment with the word
STOPDo not miss the last post from @steemitboard:
SteemitBoard and the Veterans on Steemit - The First Community Badge.
Congratulations @weaming! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Do not miss the last post from @steemitboard:
Vote for @Steemitboard as a witness to get one more award and increased upvotes!