Skip to content

Commit

Permalink
Added Errorable instances to other monads.
Browse files Browse the repository at this point in the history
Yes, they are orphan instances. No, I don't care.
I think the likelihood that the standard Reader/Writer/etc. monads
implement Errorable in their own land is low, and if they do then
just don't import Dangerous.Extensions.
  • Loading branch information
Nate Soares committed Jan 28, 2012
1 parent 9119288 commit 9ae58c2
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/Control/Dangerous/Extensions.hs
@@ -0,0 +1,30 @@
-- This is the land of the orphans, so NO WHINING
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Control.Dangerous.Extensions where
import Prelude hiding ( log )
import Control.Dangerous
import Control.Monad.Cont
import Control.Monad.Maybe
import Control.Monad.Reader
import Control.Monad.State
import Control.Monad.Writer

instance (Errorable m) => Errorable (ContT s m) where
log = lift . log
exit = lift . exit

instance (Errorable m) => Errorable (MaybeT m) where
log = lift . log
exit = lift . exit

instance (Monoid s, Errorable m) => Errorable (WriterT s m) where
log = lift . log
exit = lift . exit

instance (Errorable m) => Errorable (ReaderT s m) where
log = lift . log
exit = lift . exit

instance (Errorable m) => Errorable (StateT s m) where
log = lift . log
exit = lift . exit

0 comments on commit 9ae58c2

Please sign in to comment.