
Thank you, everyone, for the suggestions. On Mon, Mar 21, 2011 at 12:28 PM, Johannes Waldmann < waldmann@imn.htwk-leipzig.de> wrote:
Alex Rozenshteyn
writes: as part of a larger project of porting http://www.cs.jhu.edu/~scott/pl/book/dist/ from ocaml to Haskell.
Nice idea. I was using a similar approach (interpreters for various semantic domains) in a course on semantics(+ compilation).
I modelled it after the Turbak/Gifford book http://mitpress.mit.edu/catalog/item/?ttype=2&tid=11656 (in fact after the book had been praised in this here mailing list, about two years ago).
In fact the contents of these two books seem largely similar, and the following remark holds true:
Using Haskell as an implementation language, you get a very nice addition: you can model the semantics domains by Monads, and it's very natural, (Identity monad = naive interpreter, Maybe monad = for exceptions e.g. division by zero, State monad = for assignment, Continuation passing monad = for CPS style programming).
Now, neither of the books dare to use the M-word. Although Turbak is really "doing monads": he is clearly defining several "bind" and "return", he's just not naming them as such.
You may browse my source code (quite unpolished) here http://dfa.imn.htwk-leipzig.de/cgi-bin/gitweb.cgi?p=ws10-cb/.git;a=tree and there's a parser as well (in the Exp directory).
I'd be happy to get comments on my code as well. Would it look better with Monad transformers? And there's some amount of (tree walking) boilerplate that could perhaps be replaced by some template haskell magic. But then, magic is no good in teaching...
Best regards, J.W.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- Alex R