Consider the following function definition in ghci.
let myF = sin . cos . sum
Where,. means a composition of two functions (right associative). I can call it
myF [3.14, 3.14]
and it gives me the desired result. Apparently, it passes the list [3.14, 3.14] for the "sum" function, and its "result" is passed to cos and so on and on. However, if I do this in the interpreter
let myF y = sin . cos . sum y
or
let myF y = sin . cos (sum y)
then I run into problems. Changing this in the following gives me the desired result.
let myF y = sin . cos $ sum y
or
let myF y = sin . cos . sum $ y
The type (.) Assumes that there should be no problem with the following form, since "sum y" is also a function (isn't it? After all, is this all a function in Haskell?)
let myF y = sin . cos . sum y -- this should work?
More interestingly, I can get it to work with two (or many) arguments (think of passing the list [3.14, 3.14] as two arguments x and y), I have to write the following
let (myF x) y = (sin . cos . (+ x)) y myF 3.14 3.14 -- it works! let myF = sin . cos . (+) myF 3.14 3.14 -- -- Doesn't work!
There is some discussion on HaskellWiki regarding this form, which they call the "PointFree" form http://www.haskell.org/haskellwiki/Pointfree . After reading this article, I suspect that this form is different from the composition of two lambda expressions. I get confused when I try to draw a line separating both of these styles.