[Haskell-cafe] newbie "concatenating" monad question

Bryan Burgers bryan.burgers at gmail.com
Sat Mar 24 15:57:10 EDT 2007

> My idea is to have a monad with a concatenating >>, so that I can:
> bulidStuff = do
>   func1
>   func2
>   func3
>   func4

> Leandro Penz

I actually did this recently for a project I have been working on.
First, an example:

> output label a@(I.Add a1 a2 a3) = do
>   comment (show a)
>   mov' label eax a1
>   add eax a2
>   mov a3 eax

My monad in this example has a Writer or a WriterT in it somewhere. I
of course had to include the 'tell' that you mention somewhere, but I
hid it in the 'comment', 'mov', and 'add' functions in an attempt to
make my own personal assembly DSL. Obviously, you would have to either
include 'tell' in your func1, func2, etc., or create wrappers for them
that include a 'tell'.

Just my two cents.


More information about the Haskell-Cafe mailing list