I am currently reading Learn You a Haskell for Great Good! and am stumbling on the explanation for the evaluation of a certain code block. I\'ve read the explanations severa
It is using the applicative instance for functions. Your code
(+) <$> (+3) <*> (*100) $ 5
is evaluated as
( (\a->b->a+b) <$> (\c->c+3) <*> (\d->d*100) ) 5 ( (\x -> (\a->b->a+b) ((\c->c+3) x)) <*> (\d->d*100) ) 5 ( (\x -> (\a->b->a+b) (x+3)) <*> (\d->d*100) ) 5 ( (\x -> b -> (x+3)+b) <*> (\d->d*100) ) 5 ( (\x->b->(x+3)+b) <*> (\d->d*100) ) 5 (\y -> ((\x->b->(x+3)+b) y) ((\d->d*100) y)) 5 (\y -> (b->(y+3)+b) (y*100)) 5 (\y -> (y+3)+(y*100)) 5 (5+3)+(5*100)
where <$> is fmap or just function composition ., and <*> is ap if you know how it behaves on monads.