I came to understand functors, applicative functors, and monads as follows:
- Functors: calculations that can be matched.
- Applicative functors: independent calculations whose results can be combined together.
- Monad: (possible, but not necessary) dependent calculations that can be bound.
However, there is something about the fact that the Application is contrary to my understanding ... Here is an example of a Haskell parser defined based on simpler parsers using an applicative style:
(,) <$> parseName <*> parseEmail
Effects two parsers parseNameand parseEmailare not independent since they both consume tokens of the same input stream, e.g.
Jubobs jubobs@jubobs.io
parseEmailcan consume only that which has not been consumed parseName. How can we assume that the two calculations are independent?
source
share