Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1.  Is all Haskell syntax pointfree compatible? (Christopher Howard)
   2. Re:  Is all Haskell syntax pointfree compatible? (Karl Voelker)


----------------------------------------------------------------------

Message: 1
Date: Sat, 24 Nov 2012 01:13:43 -0900
From: Christopher Howard <[email protected]>
Subject: [Haskell-beginners] Is all Haskell syntax pointfree
        compatible?
To: Haskell Beginners <[email protected]>
Message-ID: <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

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

-------------- 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/20121124/d2e79fe3/attachment-0001.pgp>

------------------------------

Message: 2
Date: Sat, 24 Nov 2012 02:32:03 -0800
From: Karl Voelker <[email protected]>
Subject: Re: [Haskell-beginners] Is all Haskell syntax pointfree
        compatible?
To: Christopher Howard <[email protected]>
Cc: Haskell Beginners <[email protected]>
Message-ID:
        <caffow0xia5ckr7qufuwmlyeco9x8qiphovpkrbqfmcih4vx...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"

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 <
[email protected]> 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
> [email protected]
> 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-0001.htm>

------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 53, Issue 29
*****************************************

Reply via email to