transformers-base-0.4.1/0000755000000000000000000000000011673143660013346 5ustar0000000000000000transformers-base-0.4.1/LICENSE0000644000000000000000000000275311673143660014362 0ustar0000000000000000Copyright (c) 2011, Mikhail Vorozhtsov, Bas van Dijk All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the names of the copyright owners nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. transformers-base-0.4.1/Setup.hs0000644000000000000000000000005611673143660015003 0ustar0000000000000000import Distribution.Simple main = defaultMain transformers-base-0.4.1/transformers-base.cabal0000644000000000000000000000234311673143660017771 0ustar0000000000000000Name: transformers-base Version: 0.4.1 Category: Control Stability: experimental Synopsis: Lift computations from the bottom of a transformer stack Description: This package provides a straightforward port of @monadLib@'s BaseM typeclass to @transformers@. Homepage: https://github.com/mvv/transformers-base Bug-Reports: https://github.com/mvv/transformers-base/issues Author: Mikhail Vorozhtsov , Bas van Dijk Maintainer: Mikhail Vorozhtsov Copyright: 2011 Mikhail Vorozhtsov , Bas van Dijk License: BSD3 License-File: LICENSE Cabal-Version: >= 1.6.0 Build-Type: Simple Source-Repository head Type: git Location: https://github.com/mvv/transformers-base.git Flag OrphanInstances Description: Declare orphan Applicative instances for lazy and strict ST if needed Default: True Library Build-Depends: base >= 3 && < 5, transformers >= 0.2 Hs-Source-Dirs: src GHC-Options: -Wall if flag(OrphanInstances) CPP-Options: -DHS_TRANSFORMERS_BASE__ORPHANS=1 else CPP-Options: -DHS_TRANSFORMERS_BASE__ORPHANS=0 Exposed-Modules: Control.Monad.Base transformers-base-0.4.1/src/0000755000000000000000000000000011673143660014135 5ustar0000000000000000transformers-base-0.4.1/src/Control/0000755000000000000000000000000011673143660015555 5ustar0000000000000000transformers-base-0.4.1/src/Control/Monad/0000755000000000000000000000000011673143660016613 5ustar0000000000000000transformers-base-0.4.1/src/Control/Monad/Base.hs0000644000000000000000000000514711673143660020030 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# LANGUAGE UnicodeSyntax #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} module Control.Monad.Base ( MonadBase(..), liftBaseDefault ) where import Data.Monoid import Data.Functor.Identity import Control.Applicative (Applicative(..)) import Control.Monad.Trans.Class import Control.Monad.Trans.Identity import Control.Monad.Trans.Maybe import Control.Monad.Trans.List import Control.Monad.Trans.Reader import qualified Control.Monad.Trans.Writer.Lazy as L import qualified Control.Monad.Trans.Writer.Strict as S import qualified Control.Monad.Trans.State.Lazy as L import qualified Control.Monad.Trans.State.Strict as S import qualified Control.Monad.Trans.RWS.Lazy as L import qualified Control.Monad.Trans.RWS.Strict as S import Control.Monad.Trans.Error import Control.Monad.Trans.Cont #if !MIN_VERSION_base(4,4,0) && HS_TRANSFORMERS_BASE__ORPHANS import Control.Monad (ap) #endif #if MIN_VERSION_base(4,4,0) || HS_TRANSFORMERS_BASE__ORPHANS import qualified Control.Monad.ST.Lazy as L import qualified Control.Monad.ST.Strict as S #endif #if MIN_VERSION_base(4,3,0) import GHC.Conc.Sync (STM) #endif class (Applicative b, Applicative m, Monad b, Monad m) ⇒ MonadBase b m | m → b where -- | Lift a computation from the base monad liftBase ∷ b α → m α #define BASE(M) \ instance MonadBase (M) (M) where liftBase = id BASE(IO) BASE(Maybe) BASE(Either e) BASE([]) BASE((→) r) BASE(Identity) #if MIN_VERSION_base(4,3,0) BASE(STM) #endif #if !MIN_VERSION_base(4,4,0) && HS_TRANSFORMERS_BASE__ORPHANS instance Applicative (L.ST s) where pure = return (<*>) = ap instance Applicative (S.ST s) where pure = return (<*>) = ap #endif #if MIN_VERSION_base(4,4,0) || HS_TRANSFORMERS_BASE__ORPHANS BASE(L.ST s) BASE(S.ST s) #endif #undef BASE -- | Can be used as a default implementation for 'liftBase'. -- -- Note that: @liftBaseDefault = 'lift' . 'liftBase'@ liftBaseDefault ∷ (MonadTrans t, MonadBase b m) ⇒ b α → t m α liftBaseDefault = lift . liftBase #define TRANS(T) \ instance (MonadBase b m) ⇒ MonadBase b (T m) where liftBase = liftBaseDefault TRANS(IdentityT) TRANS(MaybeT) TRANS(ListT) TRANS(ReaderT r) TRANS(L.StateT s) TRANS(S.StateT s) TRANS(ContT r) #undef TRANS #define TRANS_CTX(CTX, T) \ instance (CTX, MonadBase b m) ⇒ MonadBase b (T m) where liftBase = liftBaseDefault TRANS_CTX(Monoid w, L.WriterT w) TRANS_CTX(Monoid w, S.WriterT w) TRANS_CTX(Monoid w, L.RWST r w s) TRANS_CTX(Monoid w, S.RWST r w s) TRANS_CTX(Error e, ErrorT e) #undef TRANS_CTX