Why wrapping the Data.Binary.Put monad creates a memory leak?

前端 未结 2 574
夕颜
夕颜 2020-12-18 23:46

I\'m trying to wrap the Data.Binary.Put monad into another so that later I can ask it questions like \"how many bytes it\'s going to write\" or \"what is the current positio

2条回答
  •  旧巷少年郎
    2020-12-19 00:26

    Did you tried to make the monad more strict? Eg. try to make the constructors of your datatyp strict / replace them with a newtype.

    I don't know what's the exact problem here, but this is the usual source of leaks.

    PS: And try to remove unnecessary lambdas, for instance:

      ma >>= f = Writer1M $ (write ma) >=> write . f
    

提交回复
热议问题