[Haskell] Monad Unification

Dominic Steinitz dominic.steinitz at blueyonder.co.uk
Thu Mar 10 16:46:33 EST 2005


Can someone explain why this works? I would have expected an error when the 
typechecker tries to unify m with (StateT [Encoding] m).

Dominic.

*Codec.ASN1.BER> :t (tc absInteger (Primitive Universal 2 1 [0]))
(tc absInteger (Primitive Universal 2 1 [0])) :: 
forall m e. (MonadError e m) => m Defaulted

*Codec.ASN1.BER> :t (\x -> k [] [])
(\x -> k [] []) :: 
forall m t e. (MonadError e m) => t -> StateT [Encoding] m [Maybe Defaulted]

*Codec.ASN1.BER> :t (>>=)
(>>=) :: forall m b a. (Monad m) => m a -> (a -> m b) -> m b

*Codec.ASN1.BER> :t ((tc absInteger (Primitive Universal 2 1 [0])) >>= (\x -> 
k [] []))
((tc absInteger (Primitive Universal 2 1 [0])) >>= (\x -> k [] [])) :: 
forall m e e1. (MonadError e1  (StateT [Encoding] m), MonadError e m) =>
   StateT [Encoding] m [Maybe Defaulted]



More information about the Haskell mailing list