On Tue, Jan 10, 2006 at 08:47:32PM +0300, Bulat Ziganshin wrote: > those rank-2 types wil make me mad :) > > encodeHelper :: (MRef m r, Binary m a, BitStream m (StringBuffer m r)) > => a -> m String > encodeHelper x = do h <- newStringBuffer "" stringBufferDefaultCloseFunc > put_ h x > getStringBuffer h > encode x = runST (encodeHelper x) > > i can't force `encode` to compile, either with or without any type > signatures. actually, signature for `encodeHelper` was developed by > Hugs, but now i don't know how to proceed further > > just now tried to force Hugs tell me its type. mission impossible :) > > DataAltBinaryClass> :t (runST (encodeHelper 1)) > ERROR - Cannot justify constraints in application > *** Expression : encodeHelper 1 > *** Type : ST c [Char] > *** Given context : () > *** Constraints : (Num b, Binary (ST c) b)
It's telling you that your expression is ill-typed, and that encodeHelper 1 :: (Num b, Binary (ST s) b) => ST s String runST is declared with an argument type in which s is unconstrained, so this is rejected. > Binary class in my library includes monad in its header. May be it's > the cause of problems? > > class Binary m a where > -- | Convert value to sequence of bits and write it to the stream > put_ :: (BitStream m h) => h -> a -> m () Yes, that's the problem. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe