[Haskell-beginners] types, parentheses, application, composition
christopher.howard at frigidcode.com
Sun Nov 25 12:27:31 CET 2012
Could someone explain more precisely to me what is the significance of
parentheses in the type of an expression? Are they just some kind of
syntactic sugar, that simplifies into a type without them, or are they
more like parentheses in algebra, or...?
In particular, I'm having difficulty understanding the results of
composition or application that involves parentheses... I think I've got
it figured out and then I find another strange expression that doesn't
have the type I expect. Here is an example using the (self-made)
> :t sqr
sqr :: Double -> Double
> :t (.)
(.) :: (b -> c) -> (a -> b) -> a -> c
> :t (. sqr)
(. sqr) :: (Double -> c) -> Double -> c
> :t ((. sqr) .)
((. sqr) .) :: (a -> Double -> c) -> a -> Double -> c
Everything makes sense up until the last expression, "((. sqr) .)".
Where did the "(a -> Double -> c)" come from? What's going on here?
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 551 bytes
Desc: OpenPGP digital signature
More information about the Beginners