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:

[hidden email]
_______________________________________________

Haskell-Cafe mailing list

[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe