Re: Writing for both State and StateT

Derek Elkins
On Tue, 22 Apr 2003 23:05:09 +0100 Alastair Reid
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.
Have you tried this? GHCi does indeed typecheck the input (``validate the constraints'' as you put it). It has to, to be a Haskell 98-conforming interpreter. Jon Cast

On Tue, 22 Apr 2003 23:27:33 -0500
Jon Cast
Derek Elkins
wrote: On Tue, 22 Apr 2003 23:05:09 +0100 Alastair Reid
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.
Have you tried this? GHCi does indeed typecheck the input (``validate the constraints'' as you put it). It has to, to be a Haskell 98-conforming interpreter.
Yes, I've tried it. I didn't mean GHCi doesn't EVER validate the constraints on input, just that it doesn't when you use :t. As :t isn't part of the language, H98 conformance doesn't matter, and as the example uses multiparameter typeclasses, it's beyond H98 anyways. For example, see SimulatingDependentTypes on the Haskell Wiki. If you type :t ex4 it will spit out the constraints in GHCi. If you type simply ex4 it will fail to typecheck.
participants (2)
-
Derek Elkins
-
Jon Cast