[Haskell-cafe] rank-2 :(
Bulat Ziganshin
bulatz at HotPOP.com
Tue Jan 10 12:47:32 EST 2006
Hello ,
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)
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 ()
but it's needed because MArray types, for example, can be serialized
only in the appropriate monad:
instance Binary IO (IOArray a) where ...
--
Best regards,
Bulat mailto:bulatz at HotPOP.com
More information about the Haskell-Cafe
mailing list