Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Lennart Augustsson <lennart <at> augustsson.net>
Subject: ANN: cmonad 0.1.1
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Sunday 29th March 2009 09:16:40 UTC (over 8 years ago)
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
 
CD: 3ms