[Haskell-beginners] Is all Haskell syntax pointfree compatible?

Karl Voelker ktvoelker at gmail.com
Sat Nov 24 11:32:03 CET 2012


Your analysis is basically correct. These syntactic features do not play
nicely with pointfree style. But I can go into a bit more detail.

It isn't surprising that do-notation prevents point-free style. The purpose
of do-notation is to provide a nicer way to bind variables in monadic code.
The goal of pointfree style is to get rid of unneeded variable bindings. In
fact, if you have a function written with do-notation that can be
translated into pointfree style, then you don't need do-notation. For
example, beginners will often write code like this:

do { x <- m ; f x }

When they could write the much simpler:

m >>= f

Record notation is a different situation. The notation itself is very
pointy, but the notation is optional. Using lenses to access and update
your records might be a good way to integrate them into pointfree code.

-Karl


On Sat, Nov 24, 2012 at 2:13 AM, Christopher Howard <
christopher.howard at frigidcode.com> wrote:

> After reading the Haskell wiki article about pointfree style I naturally
> started playing around with with converting my regular code to
> pointfree. However, I immediately got stuck on the specific cases of 1)
> do syntax and 2) record syntax. For example:
>
> code:
> --------
> playMusic rt =
>   do [source] <- genObjectNames 1
>      buffer source $= getSound rt "music.wav"
>      sourceGain source $= 0.4
>      loopingMode source $= Looping
>      play [source]
> --------
>
> And another (contrived) example:
>
> code:
> --------
> data A = A { u :: Int
>            , v :: Double
>            , w :: String
>            , ...
>            }
>
> f a b = a { v = b }
> --------
>
> --
> frigidcode.com
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20121124/dd86481e/attachment.htm>


More information about the Beginners mailing list