[Haskell-beginners] desugaring an example from RWH

Andrew Wagner wagner.andrew at gmail.com
Mon Feb 23 09:40:37 EST 2009


Here's my attempt (without a typechecker):tryBogusSale = atomically
populateWorld >>= \players@(alice:bob:_) ->
                       atomically (consistentBalance players >>=
alwaysSucceeds) >>
                       bogusSale Wand 5 alice bob

On Mon, Feb 23, 2009 at 9:33 AM, Michael Easter <codetojoy at gmail.com> wrote:

>
> Folks,
>
> I have an example of the do-syntax that I would like to desugar.  It is an
> example from Chapter 28 in RWH.
>
> I think I understand the ideas behind the following STM example, but I
> would like to present it to others in a desugared way:
>
> tryBogusSale = do
>     players@(alice:bob:_) <- atomically populateWorld
>     atomically $ alwaysSucceeds =<< consistentBalance players
>     bogusSale Wand 5 alice bob
>
> I'm having problems especially with the 2nd line in the do block (i.e. the
> predicate for alwaysSucceeds).  I would like to try and express this in
> terms of only bind (->) and return.
>
> thanks!
> Michael
>
> --
> ----------------------
> Michael Easter
> http://codetojoy.blogspot.com: Putting the thrill back in blog
>
> http://youtube.com/ocitv -> Fun people doing serious software engineering
>
> _______________________________________________
> 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/20090223/9c156025/attachment.htm


More information about the Beginners mailing list