What other ways can state be handled in a pure functional language besides with Monads?

前端 未结 7 1801
一个人的身影
一个人的身影 2020-12-23 01:58

So I started to wrap my head around Monads (used in Haskell). I\'m curious what other ways IO or state can be handled in a pure functional language (both in theory or realit

相关标签:
7条回答
  • 2020-12-23 02:50

    Another major approach is uniqueness typing, as in Clean. The short story is that handles to state (including the real world) can only be used once, and functions that access mutable state return a new handle. This means that an output of the first call is an input of a second, forcing the sequential evaluation.

    Effect typing is used in the Disciple Compiler for Haskell, but to the best of my knowledge it would take considerable compiler work to enable it in, say, GHC. I shall leave discussion of the details to those better-informed than myself.

    0 讨论(0)
提交回复
热议问题