Thanks. Specifically I was thinking of the examples about predicates.
In the section about the domain specific embedded language to search
the file system (on the pages 222, 223). The book defines a generic
predicate-like type InfoP a. This "type is just a synonym for a
function of four arguments".
type InfoP a = FilePath -- path to directory entry
-> Permissions -- permissions
-> Maybe Integer -- file size (Nothing if not file)
-> ClockTime -- last modified
-> a
A little later the equalP function is given as:
equalP :: (Eq a) => InfoP a -> a -> InfoP Bool
equalP f k = \w x y z -> f w x y z == k
I don't understand what values are bound to the variables f, k, w, x,
y and z. I believe that 'InfoP a' is bound to f and 'a' is bound to k
(ignoring w x y z for the moment) But how can that be if InfoP is just
a type synonym of a function? Shouldn't the signature of equalP be
equalP :: (Eq a) => (InfoP a) -> a -> InfoP Bool
... if you wanted to pass in a function as argument? (Or
alternatively, shouldn't you have to pass four arguments instead of
only one)? To check, I added parentheses to the signature of equalP
expecting that GHC would throw some kind of error which might give me
additional clues. But the code compiled nicely. What am I missing
here?
Then there are w, y, x and z. IMO horrible picks for variable names -
even inside a lambda expression. I assume these are parameters of the
function that is created in the lambda expression. This would imply
that the compiler is smart enough to figure out the correct types
based on the declared InfoP Bool return type. Is that correct?