Move MonadIO to base
jwlato at gmail.com
Tue Apr 13 19:33:04 EDT 2010
> From: Isaac Dupree <ml at isaac.cedarswampstudios.org>
> On 04/10/10 11:35, Twan van Laarhoven wrote:
>> If MonadIO were in base, then the base library itself could also use it.
>> For example the functions in System.IO could be lifted to work on any
>> MonadIO monad. Whether that is a good idea is completely orthogonal to
>> this discussion, however.
> I think it is relevant to the discussion to consider whether the MonadIO
> class is a good idea in general -- if it's not a broad enough use, then
> maybe we shouldn't implicitly sanction it by putting it in 'base'. Is
> it mainly to make monad-transformer code more readable* by requiring
> fewer explicit lifts? Are there other reasons? (Pointing to example
> code that uses MonadIO would be a good answer.)
I think MonadIO is essential for writing polymorphic low-level
libraries. In the iteratee library, I couldn't write e.g.
Data.Iteratee.IO.Handle.enumHandle (or any of the enumerators) without
MonadIO. This library interfaces with IO functions but it can't know
the monad stack as that is meant to be determined by the client.
Without MonadIO, I'd need to write multiple versions of the function
for each level of nesting, or clients would need to write their own
enumerators, neither of which is as good a solution as MonadIO.
> (I see nothing wrong with splitting MonadIO out into a new package
> (besides that proliferation of packages is a bit annoying)...
I wouldn't mind if a new MonadIO package, whether it's in base or not.
More information about the Libraries