Is it possible to create a Monad that count the number of instructions?

后端 未结 3 997
一生所求
一生所求 2021-01-17 20:51

Thinking about monad, it came to me the idea of a monad as the way to break with the Von Neumann architecture. The Von Neumann architecture uses a set of instructions (calle

3条回答
  •  失恋的感觉
    2021-01-17 21:02

    Your implementation throws away the number of steps in f. Shouldn't you add them?

      (Counter n1 a) >>= f = let Counter n2 b = f a
                         in (Counter (n1+n2) b)
    

提交回复
热议问题