1 {-# OPTIONS_GHC -fno-warn-orphans -fno-warn-warnings-deprecations #-}
    2 {-# LANGUAGE CPP            #-}
    3 {-# LANGUAGE PackageImports #-}
    4 
    5 -- Note re: "-fno-warn-warnings-deprecations" above: transformers has
    6 -- deprecated Control.Monad.Trans.Error (which we like) but we are going to
    7 -- provide an ErrorT instance for compatibility until the deprecated modules
    8 -- are removed.
    9 
   10 module Snap.Internal.Instances () where
   11 ------------------------------------------------------------------------------
   12 import           Control.Monad.Trans.Class         (MonadTrans (lift))
   13 import           Control.Monad.Trans.Error         (Error, ErrorT)
   14 #if MIN_VERSION_transformers(0,4,0)
   15 import           Control.Monad.Trans.Except        (ExceptT)
   16 #endif
   17 import           Control.Monad.Trans.List          (ListT)
   18 import           Control.Monad.Trans.Reader        (ReaderT)
   19 import qualified Control.Monad.Trans.RWS.Lazy      as LRWS (RWST)
   20 import           Control.Monad.Trans.RWS.Strict    (RWST)
   21 import qualified Control.Monad.Trans.State.Lazy    as LState (StateT)
   22 import           Control.Monad.Trans.State.Strict  (StateT)
   23 import qualified Control.Monad.Trans.Writer.Lazy   as LWriter (WriterT)
   24 import           Control.Monad.Trans.Writer.Strict (WriterT)
   25 import           Snap.Internal.Core                (MonadSnap (..))
   26 #if !MIN_VERSION_base(4,8,0)
   27 import           Data.Monoid                       (Monoid)
   28 #endif
   29 ------------------------------------------------------------------------------
   30 
   31 
   32 ------------------------------------------------------------------------------
   33 instance (MonadSnap m, Error e) => MonadSnap (ErrorT e m) where
   34     liftSnap = lift . liftSnap
   35 
   36 #if MIN_VERSION_transformers(0,4,0)
   37 instance (MonadSnap m, Monoid e) => MonadSnap (ExceptT e m) where
   38     liftSnap = lift . liftSnap
   39 #endif
   40 
   41 ------------------------------------------------------------------------------
   42 instance MonadSnap m => MonadSnap (ListT m) where
   43     liftSnap = lift . liftSnap
   44 
   45 
   46 ------------------------------------------------------------------------------
   47 instance (MonadSnap m, Monoid w) => MonadSnap (RWST r w s m) where
   48     liftSnap = lift . liftSnap
   49 
   50 
   51 ------------------------------------------------------------------------------
   52 instance (MonadSnap m, Monoid w) => MonadSnap (LRWS.RWST r w s m) where
   53     liftSnap = lift . liftSnap
   54 
   55 
   56 ------------------------------------------------------------------------------
   57 instance MonadSnap m => MonadSnap (ReaderT r m) where
   58     liftSnap = lift . liftSnap
   59 
   60 
   61 ------------------------------------------------------------------------------
   62 instance MonadSnap m => MonadSnap (StateT s m) where
   63     liftSnap = lift . liftSnap
   64 
   65 
   66 ------------------------------------------------------------------------------
   67 instance MonadSnap m => MonadSnap (LState.StateT s m) where
   68     liftSnap = lift . liftSnap
   69 
   70 
   71 ------------------------------------------------------------------------------
   72 instance (MonadSnap m, Monoid w) => MonadSnap (WriterT w m) where
   73     liftSnap = lift . liftSnap
   74 
   75 
   76 ------------------------------------------------------------------------------
   77 instance (MonadSnap m, Monoid w) => MonadSnap (LWriter.WriterT w m) where
   78     liftSnap = lift . liftSnap