Chapter 9. I/O case study: a library for searching the filesystem
Kushlendra Mishra:
Mostly, types and precedence:
Prelude> :i ($)
($) :: (a -> b) -> a -> b -- Defined in GHC.Base
infixr 0 $
Prelude> :i (.)
(.) :: (b -> c) -> (a -> b) -> a -> c -- Defined in GHC.Base
infixr 9 .The types mean that ($) applies an argument to a function while (.) takes two functions to combine. The "infixr" lines mean that (.) binds much tighter than ($).
"f y $ z" passes arguments "y" and "z" to function "f". Notice that ($) does its thing after "y" is passed to "f".
It's the same as "x y (z)", which is mostly useful when "z" is a really long or involves lots of parentheses."f y . z " passes the function "y . z" to function "f". Notice that "y" and "z" are combined before being passed to "f".
It's the same as "f (\x -> y (z x))"