As you can see in the source for the binary package ( Data.Binary.Put: 71 ), the data structure used for monadic values ββis strictly a builder. Since extracting a value from the monad should force the structure in which that value is found, it will cause an infinite loop if the builder is dependent on input.
data PairS a = PairS a !Builder newtype PutM a = Put { unPut :: PairS a }
So, you can write an instance of MonadFix
, but you cannot do anything about it. But I do not think that you could use anything in MonadFix
, at least nothing that you could not do with a simple old fix
, since PutM
monad is basically Writer Builder
(but with a specialized implementation).
As for your second question, this is not related to the first, so you should ask him a separate question.
source share