packages feed

contstuff-transformers (empty) → 0.1.0

raw patch · 4 files changed

+180/−0 lines, 4 filesdep +basedep +contstuffdep +transformerssetup-changed

Dependencies added: base, contstuff, transformers

Files

+ Control/ContStuff/Transformers.hs view
@@ -0,0 +1,105 @@+-- |+-- Module:     Control.ContStuff.Transformers+-- Copyright:  (c) 2010 Ertugrul Soeylemez+-- License:    BSD3+-- Maintainer: Ertugrul Soeylemez <es@ertes.de>+-- Stability:  experimental+--+-- This package provides contstuff transformer class instances for the+-- monad transformers from the transformers package as well as+-- transformers class instances for the monad transformers from+-- contstuff.  This makes using both transformer libraries in a single+-- project much more convenient as you get along with a single set of+-- lifting functions.++{-# LANGUAGE TypeFamilies #-}++module Control.ContStuff.Transformers+    ( -- * Exported from transformers+      MonadIO(..),+      MonadTrans,+      liftT+    )+    where++import qualified Control.Monad.Trans.Class as T+import qualified Control.ContStuff.Trans as C+import Control.ContStuff.Classes as C+import Control.Monad.IO.Class (MonadIO(..))+import Control.Monad.Trans.Class (MonadTrans)+import Data.Monoid++import qualified Control.Monad.Trans.Cont          as T (ContT)+import qualified Control.Monad.Trans.Error         as T (Error, ErrorT)+import qualified Control.Monad.Trans.List          as T (ListT)+import qualified Control.Monad.Trans.RWS.Lazy      as T (RWST)+import qualified Control.Monad.Trans.RWS.Strict    as TS (RWST)+import qualified Control.Monad.Trans.Reader        as T (ReaderT)+import qualified Control.Monad.Trans.State.Lazy    as T (StateT)+import qualified Control.Monad.Trans.State.Strict  as TS (StateT)+import qualified Control.Monad.Trans.Writer.Lazy   as T (WriterT)+import qualified Control.Monad.Trans.Writer.Strict as TS (WriterT)+++-- ====================== --+-- Interface to monads-tf --+-- ====================== --++-- | Interface to 'Control.Monad.Trans.lift'.++liftT :: (Monad m, MonadTrans t) => m a -> t m a+liftT = T.lift+++-- ============================================== --+-- monads-tf instances for ContStuff transformers --+-- ============================================== --++instance MonadTrans (C.ChoiceT r i) where lift = C.lift+instance MonadTrans (C.ContT r)     where lift = C.lift+instance MonadTrans (C.EitherT r e) where lift = C.lift+instance MonadTrans (C.MaybeT r)    where lift = C.lift+instance MonadTrans (C.StateT r s)  where lift = C.lift++instance MonadIO m => MonadIO (C.ChoiceT r i m) where liftIO = liftT . liftIO+instance MonadIO m => MonadIO (C.ContT r m)     where liftIO = liftT . liftIO+instance MonadIO m => MonadIO (C.EitherT r e m) where liftIO = liftT . liftIO+instance MonadIO m => MonadIO (C.MaybeT r m)    where liftIO = liftT . liftIO+instance MonadIO m => MonadIO (C.StateT r s m)  where liftIO = liftT . liftIO+++-- ============================================== --+-- ContStuff instances for monads-tf transformers --+-- ============================================== --++instance Transformer (T.ContT r) where lift = liftT+instance T.Error e => Transformer (T.ErrorT e) where lift = liftT+instance Transformer (T.ListT) where lift = liftT+instance Monoid w => Transformer (T.RWST r w s) where lift = liftT+instance Monoid w => Transformer (TS.RWST r w s) where lift = liftT+instance Transformer (T.ReaderT r) where lift = liftT+instance Transformer (T.StateT s) where lift = liftT+instance Transformer (TS.StateT s) where lift = liftT+instance Monoid w => Transformer (T.WriterT w) where lift = liftT+instance Monoid w => Transformer (TS.WriterT w) where lift = liftT++instance (LiftBase m, Monad m) => LiftBase (T.ContT r m) where+    type Base (T.ContT r m) = Base m; base = lift . base+instance (T.Error e, LiftBase m, Monad m) => LiftBase (T.ErrorT e m) where+    type Base (T.ErrorT e m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (T.ListT m) where+    type Base (T.ListT m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (T.RWST r w s m) where+    type Base (T.RWST r w s m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (TS.RWST r w s m) where+    type Base (TS.RWST r w s m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (T.ReaderT r m) where+    type Base (T.ReaderT r m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (T.StateT s m) where+    type Base (T.StateT s m) = Base m; base = lift . base+instance (LiftBase m, Monad m) => LiftBase (TS.StateT s m) where+    type Base (TS.StateT s m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (T.WriterT w m) where+    type Base (T.WriterT w m) = Base m; base = lift . base+instance (LiftBase m, Monad m, Monoid w) => LiftBase (TS.WriterT w m) where+    type Base (TS.WriterT w m) = Base m; base = lift . base
+ LICENSE view
@@ -0,0 +1,32 @@+contstuff-monads-tf license+Copyright (c) 2010, Ertugrul Soeylemez++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 name of the author nor the names of any 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.
+ Setup.lhs view
@@ -0,0 +1,12 @@+contstuff-monads-tf setup script+Copyright (C) 2010, Ertugrul Soeylemez++Please see the LICENSE file for terms and conditions of use,+modification and distribution of this package, including this file.++> module Main where+>+> import Distribution.Simple+>+> main :: IO ()+> main = defaultMain
+ contstuff-transformers.cabal view
@@ -0,0 +1,31 @@+Name:          contstuff-transformers+Version:       0.1.0+Category:      Control, Monads+Synopsis:      ContStuff instances for transformers and vice-versa+Maintainer:    Ertugrul Söylemez <es@ertes.de>+Author:        Ertugrul Söylemez <es@ertes.de>+Copyright:     (c) 2010 Ertugrul Söylemez+License:       BSD3+License-file:  LICENSE+Build-type:    Simple+Stability:     experimental+Cabal-version: >= 1.6+Description:++    This package provides contstuff transformer class instances for the+    monad transformers from the transformers package as well as+    transformers class instances for the monad transformers from+    contstuff.  This makes using both transformer libraries in a single+    project much more convenient as you get along with a single set of+    lifting functions.++Library+    Build-depends:+        base >= 4 && <= 5,+        contstuff >= 0.7.0,+        transformers >= 0.2.2.0+    GHC-Options: -W+    Extensions:+        TypeFamilies+    Exposed-modules:+        Control.ContStuff.Transformers