Writing for both State and StateT

Derek Elkins ddarius@hotpop.com
Tue, 22 Apr 2003 23:42:13 -0700


On Tue, 22 Apr 2003 23:05:09 +0100
Alastair Reid <alastair@reid-consulting-uk.ltd.uk> wrote:

> 
> > Unfortunately, in this case, with that function in isolation I get,
> 
> > Ambiguous type variable(s) `s', `m' in the constraint
> > `MonadState s m' arising from use of `get' ....
> 
> An easy way to get round this is to give a completely bogus type
> signature like:
> 
>   foo :: a
> 
> The compiler will report a mismatch and the error message will tell
> you what it thinks the type is.

Or the straightforward and simple answer: in GHCi or Hugs, just do :t f.  E.g. :t get ==> (MonadState s m) => m s. GHCi (and I imagine Hugs too) doesn't try to validate the constraints.