Closed k0001 closed 7 years ago
liftLog
is a terrible name.
I've decided against this.
The reason is that the only function where this matters is log
, and if you do have some IO
-based Monad
Foo
that doesn't implement MonadIO
, then you can just do:
fooLog :: Monoid path => Di level path msg -> level -> msg -> Foo ()
fooLog = \di l m -> UnsafeFooWhatever (liftIO (Di.log di l m))
Doing this is cheaper that having to maintain a new MonadXxx
typeclass which would need a new instance for every new monad.
Di
needsIO
to work, we acknowledge that, but sometimes theMonad
on which you are trying to useDi
deliberately doesn't supportMonadIO
, likely so that it can provide a safe interface and prevent arbitraryIO
for being called.We propose changing functions like
err :: MonadIO m => Di path msg -> msg -> m ()
toerr :: MonadDi m => Di path msg -> msg -> m ()
, where:The cost of doing this, of course, is that now we need to provide
MonadDi
instances for every monad transformer. We can do that for all of the ones intransformers
.Thanks @shlevy for the suggestion