Why does Haskell not have an I Monad (for input only, unlike the IO monad)?

后端 未结 5 1226
攒了一身酷
攒了一身酷 2021-02-18 15:29

Conceptually, it seems that a computation that performs output is very different from one that performs input only. The latter is, in one sense, much purer.

I, for one,

5条回答
  •  攒了一身酷
    2021-02-18 15:31

    I think the division between pure and impure code is somewhat arbitrary. It depends on where you put the barrier. Haskell's designers decided to clearly separate pure functional part of the language from the rest.

    So we have IO monad which incorporates all the possible effects (as different, as disk reads/writes, networking, memory access). And language enforces a clear division by means of return type. And this induces a kind of thinking which divides everything in pure and impure.

    If the information security is concerned, it would be quite naturally to separate reading and writing. But for haskell's initial goal, to be a standard lazy pure functional language, it was an overkill.

提交回复
热议问题