Move MonadIO to base
ml at isaac.cedarswampstudios.org
Thu Apr 15 00:32:26 EDT 2010
On 04/13/10 00:24, Antoine Latter wrote:
> On Mon, Apr 12, 2010 at 8:53 PM, Isaac Dupree
> <ml at isaac.cedarswampstudios.org> wrote:
>> 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.)
> This is the code which prompted my original thread:
> So the answer to your question is 'polymorphism'.
>> *i've grown increasingly doubtful of the idea that more classes /
>> less-explicit code reliably makes things more readable.
> Perhaps true! At the time I wrote the above, I was frustrated with
> having to nail myself down to a particular technique of
> signaling/expressing errors, so I erred on the side of polymorphism.
Ah, I see. Once you make the erroring portion class-based, you have no
choice but to also use MonadIO, because you've lost the ability to
explicitly use the "IO" type.
If it weren't for that issue, I'd be tempted to say:
Don't show me the benefit to providers-of-interfaces (who can become
more polymorphic in name, frequently while remaining equally powerful --
such as the Data.Map.lookup Maybe-vs-MonadPlus debates we've had --
where either function can be defined in terms of the other one*).
Rather, I'm interested in the users of those potentially-more-general
functions (both of the more-powerful and equally-powerful sorts), so
that we can all get a better intuition of when/whether it's worth it to
use MonadIO in interfaces.
*I wonder if Conor McBride has thoughts, because I thought his thoughts
on that previous debate were worth hearing
More information about the Libraries