[Haskell-cafe] GHCi infers a type but refuses it as type signature

Eric Dedieu papa.eric at free.fr
Tue Jun 23 20:05:46 EDT 2009


Thanks for your answers. I still have a question, though...

> I think the reasoninging here is the following: If MonadState is part
> of the standard library and it needs this extension to work, then all
> compilers must support this extension.

Yes, exactly, that was my point.
 
> I'm not completely sure how "standard" the MonadState class is
> though. Also, it might be that there could be implementations of
> MonadState that do not use the extension?

And indeed, I understand from the next (Luke Palmer's) answer that the
community does not fully agree on what should be standard:

> However, your question is rather moot here, as you are using the
> *mtl.  *It uses UndecidableInstances, whose blessing into the de
> facto standard would require as a precondition the batshit-insanity
> of the de facto community.
> 
> I personally use *transformers* as my monad library, as it is (as far
> as I know) the only Haskell 98 monad library on Hackage (you'll
> hardly notice the more explicit lifts, I promise!).

I just looked through Transformers and it does not define MonadState,
indeed.

Well... I am a beginner in haskell. I have
detailed in the first post the very simplistic example I was trying to
set up, the level of a beginner's tutorial. As anyone discovering a new
language, I certainly did not intend to look so soon at compiler
extensions.

Now, trying to avoid duplicate code at this very level of simplicity
seems to require compiler extensions! Here it is:

- The MonadState type seems required to reuse the same code for "State
  s a" and "StateT s IO a".

- MonadState needs compiler extensions and is implemented using the mtl
  library which seems to have drawbacks.


So

1) How can I use transformers instead of the mtl? This is in no
tutorial, and searchinf for "mtl" on the haskell wiki yields no
result at all.

2) What should be the Haskell98-compatible type signature for my play2 function, instead of (MonadState [a] m, Eq a) =>
a -> m Bool ?


Thanks again.


More information about the Haskell-Cafe mailing list