[Haskell-cafe] better way to do this?

Ketil Malde ketil at malde.org
Wed Oct 7 05:13:19 EDT 2009

Peter Verswyvelen <bugfact at gmail.com> writes:

> So yes, without using IO, Haskell forces you into this safe spot

One could argue that IO should be broken down into a set of "sub-monads"
encapsulating various subsets of the functionality - file system,
network access, randomness, and so on.  This could extend the "safe
spot" to cover much more computational real estate, and effectively
sandbox programs in various ways.

So instead of 'main :: IO ()', a text processing program using stdin and
stdout could have type 'main :: MonadStdIO m => m ()'.  For testing, you
could then define your own monad implementing 'putStrLn' and 'readLn'
etc, and a function 'runStdIO :: MonadStdIO m => m () -> String' that
you are free to use in your quickcheck properties.

(ObAttribution: I think it was a posting by Lennart Augustsson on unique
names that brought this to my mind, but a quick googling didn't find
that exact mail.) 

If I haven't seen further, it is by standing in the footprints of giants

More information about the Haskell-Cafe mailing list