[Haskell-cafe] A catch-all MonadIO instance
Bas van Dijk
v.dijk.bas at gmail.com
Fri Oct 28 16:11:11 CEST 2011
Hello,
Is it unsafe to add the following catch-all MonadIO instance to
transformers' Control.Monad.IO.Class module?
{-# LANGUAGE FlexibleInstances, FlexibleContexts, UndecidableInstances #-}
instance (MonadTrans t, Monad (t m), MonadIO m) => MonadIO (t m) where
liftIO = lift . liftIO
It could get rid of all the similarly looking instances:
instance (MonadIO m) => MonadIO (ReaderT r m) where
liftIO = lift . liftIO
instance (MonadIO m) => MonadIO (StateT s m) where
liftIO = lift . liftIO
instance (Monoid w, MonadIO m) => MonadIO (WriterT w m) where
liftIO = lift . liftIO
...
The reason I ask is that I want to do something similar for
monad-control's MonadControlIO type class. But I'm not sure if I don't
introduce any undecidability in the type-checker.
Regards,
Bas
More information about the Haskell-Cafe
mailing list