[Haskell-beginners] Understanding Monadic I/O

David Virebayre dav.vire+haskell at gmail.com
Thu Jan 14 07:52:01 EST 2010

On Mon, Jan 11, 2010 at 2:57 PM, Markus Böhm
<markus.boehm at googlemail.com> wrote:
> Hi, I'd like to understand in principle, how monadic I/O actions and
> combinators (>>=) are translated into imperative C--, to be executed
> sequentially.
> Does sequencing of IO actions mean nesting of C-- functions and
> passing values/state via additional function parameters?
> Is there any material with examples available?

Perhaps you could download JHC and compile with the -d c  flag.
It writes the C code, and JHC writes more understandable C code
compared to GHC (IMHO)

for example,

main = putStrLn "hello, world" >> putStrLn "hello again, world"

compiles to

[lots of stuff]

static void A_STD
        return (void)jhc_utf8_putchar((int)10);

so in this simple example you see there's no nesting of functions.


More information about the Beginners mailing list