[Haskell-cafe] What monad am I in?

Henry Laxen nadine.and.henry at pobox.com
Tue Sep 2 16:25:16 EDT 2008

Dear Group,

When I fire up ghci and define:

increment x = return (x+1)

I can say:
Main> increment 1

and ghci dutifully replies 2. Also as expected, the type signature of 
increment is:  (Num a, Monad m) => a -> m a

However, if I say:

Main> let a = increment 1

I get:

    Ambiguous type variable `m' in the constraint:
      `Monad m' arising from a use of `increment' at <interactive>:1:8-18
    Probable fix: add a type signature that fixes these type variable(s)

Have I, like Monsier Jourdain, been running in the IO monad all my
life, and didn't even know it?

Henry Laxen

More information about the Haskell-Cafe mailing list