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


conceptually, seems computation performs output different 1 performs input only. latter is, in 1 sense, purer.

i, one, have way separate input parts of programme ones might write out.

so, why there no input monad?

any reason why wouldn't work have monad (and o monad, combined io monad)?

edit: meant input reading files, not interacting user. use case, can assume input files not change during execution of programme (otherwise, it's fine undefined behaviour).

i disagree bdonlan's answer. it's true neither input nor output more "pure" are quite different. it's quite valid critique io single "sin bin" effects crammed together, , make ensuring properties harder. example, if have many functions know read memory locations, , never cause locations altered, nice know can reorder execution. or if have program uses forkio , mvars, nice know, based on type, isn't reading /etc/passwd.

furthermore, 1 can compose monadic effects in fashion besides stacked transformers. can't all monads (just free monads), case that's need. iospec package, example, provides pure specification of io -- doesn't seperate reading , writing, seperate them from, e.g., stm, mvars, forkio, soforth.

http://hackage.haskell.org/package/iospec

the key ideas how can combine different monads cleanly described in data types la carte paper (great reading, influential, can't recommend enough, etc.etc.).


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -