
Am Sonntag, 22. Februar 2009 18:53 schrieb David Menendez:
On Sun, Feb 22, 2009 at 9:20 AM, Luis O'Shea
wrote: test3 :: MonadState Integer m => String -> m String
Good point. It's interesting that this allows the signature of test5b to become MonadState Integer m => m Integer (instead of (Monad m) => StateT Integer (StateT String m) Integer) which is more general, and (surprisingly to me) does not mention String.
Odd. If I break up test5b like so:
test5b = flip execStateT 0 . flip evalStateT "" $ test5bImpl
test5bImpl = do modifyM test3 lift . modify $ \x -> x*2 + 1 modifyM test3 lift . modify $ \x -> x*x modifyM test3
and ask GHCi for the types, I get:
*Main> :t test5bImpl test5bImpl :: (MonadState Integer m) => StateT String m () *Main> :t test5b test5b :: (Monad m) => m Integer
Okay, you've found a bug in the type checker, 6.4.2 infers the types test5b :: (Monad (StateT [Char] (StateT s m)), MonadState s (StateT s m), Num s, Monad m) => m s test5bImpl :: (Monad (StateT [Char] m), MonadState s m, Num s) => StateT [Char] m () as does 6.6.1. That does look more reasonable.