[Haskell] ANN: cmonad 0.1.1

Lennart Augustsson lennart at augustsson.net
Sun Mar 29 05:16:40 EDT 2009


I've uploaded my CMonad package to Hackage.  It allows you to write
Haskell code in a C style.
Unfortunately, GHC lacks certain optimizations to make efficient code
when using CMonad,
so instead of C speed you get low speed.

Example: Computing some Fibonacci numbers:
fib = do {
    a <- arrayU[40];
    i <- auto 0;
    a[0] =: 1;
    a[1] =: 1;
    for (i =: 2, (i :: EIO Int) < 40, i += 1) $ do {
        a[i] =: a[i-1] + a[i-2];
    };
    retrn (a[39]);
  }


Example: Copying stdin to stdout:
cat = do {
    c <- auto 0;

    while ((c =: getchar()) >= 0) $ do {
        putchar(c);
    };
    return ();
  }

    -- Lennart


More information about the Haskell mailing list