Hi, all
I'm having trouble in understanding function evaluation in Haskell.
I came across the following line, which is somewhat cryptic to me.
(liftM . (+)) 1 [2]
Could you explain how the expression evaluates?
I thought that to evalutate two composed functions,
I should apply right function to get a result and then
apply left function with the result.
e.g. f.g x y = f (g x y) = f z = result
So I guessed that Haskell evaluated above expression
as follows:
(liftM . (+)) 1 [2] --->
((liftM . (+)) 1) [2] ---> (A)
(liftM (+1)) [2] -->
[3]
Why did Haskell, however, not try to fully evaluate addition,
like following?
(liftM . (+)) 1 [2] --->
liftM ((+) 1 [2]) --->
error
Does (f . g) x y z equal ((((f . g) x) y) z) in haskell?
Any guide will be appreciated.
Chul-Woong