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

Brandon Allbery allbery.b at gmail.com
Sun Nov 25 15:43:00 CET 2012


On Sun, Nov 25, 2012 at 6:27 AM, Christopher Howard <
christopher.howard at frigidcode.com> wrote:

> 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
>

One thing you're missing is that parentheses often have multiple meanings.
 Specifically, the thing that's tripping you up is a section:  a partially
applied operator.

(+) is an operator, with parentheses around it to turn it into a function.
 You can sometimes see this passed to e.g. fmap.

By extension, (5 +) is a section:  the operator (+) with its left parameter
applied already, equivalent to \x -> 5 + x.  (+ 5) has applied the right
parameter instead of the left.

If you have a parenthesized thing that starts or ends with an operator,
it's a section.  Your example "> :t ((. sqr) .)" has two of them, both
partially applying (.).

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix/linux, openafs, kerberos, infrastructure          http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121125/5e739c8d/attachment.htm>


More information about the Beginners mailing list