1 {-# OPTIONS_GHC -fno-warn-orphans #-}
    2 {-# LANGUAGE PackageImports #-}
    3 
    4 module Snap.Internal.Instances where
    5 
    6 import                       Control.Applicative
    7 import                       Control.Monad.Cont
    8 import                       Control.Monad.Error
    9 import                       Control.Monad.List
   10 import                       Control.Monad.RWS.Strict hiding (pass)
   11 import qualified             Control.Monad.RWS.Lazy as LRWS
   12 import                       Control.Monad.Reader
   13 import                       Control.Monad.State.Strict
   14 import qualified             Control.Monad.State.Lazy as LState
   15 import                       Control.Monad.Writer.Strict hiding (pass)
   16 import qualified             Control.Monad.Writer.Lazy as LWriter
   17 import                       Prelude hiding (catch)
   18 
   19 ------------------------------------------------------------------------------
   20 import                       Snap.Internal.Types
   21 
   22 
   23 ------------------------------------------------------------------------------
   24 instance MonadPlus m => MonadPlus (ContT c m) where
   25     mzero = lift mzero
   26     m `mplus` n = ContT $ \ f -> runContT m f `mplus` runContT n f
   27 
   28 
   29 ------------------------------------------------------------------------------
   30 instance MonadPlus m => Alternative (ContT c m) where
   31     empty = mzero
   32     (<|>) = mplus
   33 
   34 
   35 ------------------------------------------------------------------------------
   36 instance MonadSnap m => MonadSnap (ContT c m) where
   37     liftSnap = lift . liftSnap
   38 
   39 
   40 ------------------------------------------------------------------------------
   41 instance (MonadSnap m, Error e) => MonadSnap (ErrorT e m) where
   42     liftSnap = lift . liftSnap
   43 
   44 
   45 ------------------------------------------------------------------------------
   46 instance MonadSnap m => MonadSnap (ListT m) where
   47     liftSnap = lift . liftSnap
   48 
   49 
   50 ------------------------------------------------------------------------------
   51 instance (MonadSnap m, Monoid w) => MonadSnap (RWST r w s m) where
   52     liftSnap = lift . liftSnap
   53 
   54 
   55 ------------------------------------------------------------------------------
   56 instance (MonadSnap m, Monoid w) => MonadSnap (LRWS.RWST r w s m) where
   57     liftSnap = lift . liftSnap
   58 
   59 
   60 ------------------------------------------------------------------------------
   61 instance MonadSnap m => MonadSnap (ReaderT r m) where
   62     liftSnap = lift . liftSnap
   63 
   64 
   65 ------------------------------------------------------------------------------
   66 instance MonadSnap m => MonadSnap (StateT s m) where
   67     liftSnap = lift . liftSnap
   68 
   69 
   70 ------------------------------------------------------------------------------
   71 instance MonadSnap m => MonadSnap (LState.StateT s m) where
   72     liftSnap = lift . liftSnap
   73 
   74 
   75 ------------------------------------------------------------------------------
   76 instance (MonadSnap m, Monoid w) => MonadSnap (WriterT w m) where
   77     liftSnap = lift . liftSnap
   78 
   79 
   80 ------------------------------------------------------------------------------
   81 instance (MonadSnap m, Monoid w) => MonadSnap (LWriter.WriterT w m) where
   82     liftSnap = lift . liftSnap