[plt-scheme] computational expressions

From: John Clements (clements at brinckerhoff.org)
Date: Tue Mar 16 19:03:08 EDT 2010

Which is better? Haskell or F#?

Wait, wait, no, that's not what I meant at all.

I was reading up on F#'s computational expressions last night, and I'm impressed by their flexibility.  I do see one teeny tiny thing that's missing, though.

In particular, it looks like computation expressions (e.g.

parse { let! e = token
       return e}

Are a lot like Haskell's monads. In fact, in one way they're nicer; rather than just bind and return, you get a whole bunch of syntactic forms that you can redefine.

But! If I understand correctly, these overridings happen only within the syntactic boundaries of the curly braces, right?  So you couldn't abstract over those pieces in quite the same way.


let myReturn x = return x;;

parse { let! t = token
        myReturn t}

... wouldn't work, right?

Whereas Haskell gets it right:

myReturn = return

p = do t <- token
       myReturn t

I haven't tried actually running any of this, mind you. Of course, Scheme can't do this, either; it's a consequence of Haskell's truly insane type system.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2484 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100316/1f07cc43/attachment.p7s>

Posted on the users mailing list.