How to write a monad that prints “step i of N” when executing each statement in the monad?

后端 未结 5 1394
清歌不尽
清歌不尽 2021-02-15 10:38

I\'m not even sure this is possible in any kind of monad; does it violate monad laws? But it seems like something that should be possible in some kind of construct or other. S

5条回答
  •  死守一世寂寞
    2021-02-15 11:25

    Use a monad transformer to stack on a WriterT that counts how many >>'s and >>='s have been applied to the underlying monad.

提交回复
热议问题