[Haskell-cafe] Monad Imparative Usage Example

Kaveh Shahbazian kaveh.shahbazian at gmail.com
Wed Aug 2 05:56:10 EDT 2006


Haskell is the most powerfull and interesting "thing" I'v ever
encountered in IT world. But with an imparative background and lack of
understanding (because of any thing include that maybe I am not that
smart) has brought me problems. I know this is an old issue. But
please help it.
Question : Could anyone show me a sample of using a monad as a
statefull variable?
For example see this code in C# :
//
public class Test
{
    int var;
    static void Fun1() { var = 0; Console.Write(var); }
    static void Fun2() { var = var + 4; Console.Write(var); }
    static void Main() { Fun1(); Fun2(); var = 10; Console.Write("var
= " + var.ToString()); }
}
//
I want to see this code in haskell.
Thankyou


More information about the Haskell-Cafe mailing list