[Haskell-beginners] types, parentheses, application, composition

Christopher Howard 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)
function "sqr":

code:
--------
> :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?

-- 
frigidcode.com

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121125/7e9b4250/attachment.pgp>


More information about the Beginners mailing list