monadLib 3.8 → 3.9
raw patch · 4 files changed
+30/−18 lines, 4 filesdep ~base
Dependency ranges changed: base
Files
- CHANGES +4/−0
- monadLib.cabal +2/−10
- src/MonadLib.hs +20/−7
- src/MonadLib/Monads.hs +4/−1
CHANGES view
@@ -1,3 +1,7 @@+Version 3.0+ * Add instane from `MonadFail`---none of the transformers implement this+ functionality so the implementation just lifts things.+ Version 3.8 * Added `WithBase`
monadLib.cabal view
@@ -1,5 +1,5 @@ Name: monadLib-Version: 3.8+Version: 3.9 License: BSD3 License-file: LICENSE Author: Iavor S. Diatchki@@ -15,10 +15,6 @@ README, CHANGES -Flag base3- Description: Build for compatability with base3- Default: False- Library hs-source-dirs: src Exposed-modules:@@ -26,11 +22,7 @@ MonadLib.Monads, MonadLib.Derive - if flag(base3)- Build-depends: base < 4- CPP-options: -DUSE_BASE3- else- Build-depends: base >= 4 && < 5+ Build-depends: base >= 4 && < 5 GHC-options: -O2 -Wall
src/MonadLib.hs view
@@ -46,11 +46,12 @@ handle, WithBase, - -- * Miscellaneous- version, module Control.Monad ) where +#if __GLASGOW_HASKELL__ < 800+import Data.Monoid+#endif import Control.Applicative import Control.Monad@@ -63,13 +64,12 @@ import qualified Control.Exception as IO (SomeException) #endif import System.Exit(ExitCode,exitWith)-import Data.Monoid import Data.Kind(Type) import Prelude hiding (Ordering(..))---- | The current version of the library.-version :: (Int,Int,Int)-version = (3,5,2)+#if __GLASGOW_HASKELL__ >= 800+import qualified Control.Monad.Fail as MF+import Control.Monad.Fail(MonadFail)+#endif -- $Types@@ -264,6 +264,9 @@ t_fail :: (MonadT t, Monad m) => String -> t m a t_fail x = lift (fail x) +t_fail' :: (MonadT t, MonadFail m) => String -> t m a+t_fail' x = lift (MF.fail x)+ t_mzero :: (MonadT t, MonadPlus m) => t m a t_mzero = lift mzero @@ -854,3 +857,13 @@ WithBase b (f ': fs) = f (WithBase b fs) +#if __GLASGOW_HASKELL__ >= 800+instance MonadFail m => MonadFail (IdT m) where fail = t_fail'+instance MonadFail m => MonadFail (ReaderT i m) where fail = t_fail'+instance (Monoid i, MonadFail m)+ => MonadFail (WriterT i m) where fail = t_fail'+instance MonadFail m => MonadFail (StateT i m) where fail = t_fail'+instance MonadFail m => MonadFail (ExceptionT i m) where fail = t_fail'+instance MonadFail m => MonadFail (ChoiceT m) where fail = t_fail'+instance MonadFail m => MonadFail (ContT i m) where fail = t_fail'+#endif
src/MonadLib/Monads.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE Safe #-}+{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-| This module contains a collection of monads that@@ -15,9 +16,11 @@ ) where import MonadLib import MonadLib.Derive-import Control.Applicative import Control.Monad.Fix+#if __GLASGOW_HASKELL__ < 800 import Data.Monoid+import Control.Applicative+#endif newtype Reader i a = R' { unR :: ReaderT i Id a } newtype Writer i a = W' { unW :: WriterT i Id a }