packages feed

these 0.2 → 0.3

raw patch · 4 files changed

+39/−25 lines, 4 files

Files

Control/Monad/Chronicle.hs view
@@ -1,21 +1,16 @@ module Control.Monad.Chronicle ( -                               -- * The Chronicle monad-                                 Chronicle, chronicle, runChronicle+                               -- * Type class for Chronicle-style monads+                                 MonadChronicle(..)                                -- * The ChronicleT monad transformer-                               , ChronicleT(..)-                               -- * Chronicle operations-                               , dictate, confess-                               , memento, absolve, condemn, retcon-                               , module Data.Semigroup+                               , Chronicle, runChronicle, ChronicleT(..)                                , module Data.Monoid                                , module Control.Monad                                , module Control.Monad.Trans                                ) where -import Data.Semigroup (Semigroup(..)) import Data.Monoid (Monoid(..))  import Control.Monad import Control.Monad.Trans-import Control.Monad.Trans.Chronicle-+import Control.Monad.Trans.Chronicle (Chronicle, runChronicle, ChronicleT(..))+import Control.Monad.Chronicle.Class
Control/Monad/Chronicle/Class.hs view
@@ -12,11 +12,14 @@ -- non-fatal errors. -- ------------------------------------------------------------------------------module Control.Monad.Chronicle.Class (MonadChronicle(..)) where+module Control.Monad.Chronicle.Class (+    MonadChronicle(..),+    ChronicleT(..), runChronicle+    ) where  import Data.These-import Control.Applicative-import Control.Monad.Trans.Chronicle (ChronicleT)+import Control.Applicative (Applicative(..), (<$>))+import Control.Monad.Trans.Chronicle (ChronicleT, runChronicle) import qualified Control.Monad.Trans.Chronicle as Ch  import Control.Monad.Trans.Identity as Identity@@ -31,14 +34,10 @@ import Control.Monad.Trans.Writer.Strict as StrictWriter  import Control.Monad.Trans.Class (lift)-import Control.Exception (IOException, catch, ioError)-import Control.Monad-import Control.Monad.Instances ()+import Control.Monad (liftM) import Data.Monoid-import Prelude -- (Either(..), (.), IO)  - class (Monad m) => MonadChronicle c m | m -> c where     -- | @'dictate' c@ is an action that records the output @c@.     --   @@ -85,7 +84,7 @@  instance (Monoid c) => MonadChronicle c (These c) where     dictate c = These c ()-    confess = This+    confess c = This c     memento (This c) = That (Left c)     memento m = mapThat Right m     absolve x (This _) = That x@@ -141,20 +140,20 @@     retcon f (ReaderT m) = ReaderT $ retcon f . m     chronicle = lift . chronicle -instance (Monoid s, MonadChronicle c m) => MonadChronicle c (LazyState.StateT s m) where+instance (MonadChronicle c m) => MonadChronicle c (LazyState.StateT s m) where     dictate = lift . dictate     confess = lift . confess-    memento (LazyState.StateT m) = LazyState.StateT $ \s ->+    memento (LazyState.StateT m) = LazyState.StateT $ \s -> do         either (\c -> (Left c, s)) (\(a, s') -> (Right a, s')) `liftM` memento (m s)     absolve x (LazyState.StateT m) = LazyState.StateT $ \s -> absolve (x, s) $ m s     condemn (LazyState.StateT m) = LazyState.StateT $ condemn . m     retcon f (LazyState.StateT m) = LazyState.StateT $ retcon f . m     chronicle = lift . chronicle -instance (Monoid s, MonadChronicle c m) => MonadChronicle c (StrictState.StateT s m) where+instance (MonadChronicle c m) => MonadChronicle c (StrictState.StateT s m) where     dictate = lift . dictate     confess = lift . confess-    memento (StrictState.StateT m) = StrictState.StateT $ \s ->+    memento (StrictState.StateT m) = StrictState.StateT $ \s -> do         either (\c -> (Left c, s)) (\(a, s') -> (Right a, s')) `liftM` memento (m s)     absolve x (StrictState.StateT m) = StrictState.StateT $ \s -> absolve (x, s) $ m s     condemn (StrictState.StateT m) = StrictState.StateT $ condemn . m@@ -179,6 +178,26 @@     absolve x (StrictWriter.WriterT m) = StrictWriter.WriterT $ absolve (x, mempty) m     condemn (StrictWriter.WriterT m) = StrictWriter.WriterT $ condemn m     retcon f (StrictWriter.WriterT m) = StrictWriter.WriterT $ retcon f m+    chronicle = lift . chronicle++instance (Monoid w, MonadChronicle c m) => MonadChronicle c (LazyRWS.RWST r w s m) where+    dictate = lift . dictate+    confess = lift . confess+    memento (LazyRWS.RWST m) = LazyRWS.RWST $ \r s ->+        either (\c -> (Left c, s, mempty)) (\(a, s', w) -> (Right a, s', w)) `liftM` memento (m r s)+    absolve x (LazyRWS.RWST m) = LazyRWS.RWST $ \r s -> absolve (x, s, mempty) $ m r s+    condemn (LazyRWS.RWST m) = LazyRWS.RWST $ \r s -> condemn $ m r s+    retcon f (LazyRWS.RWST m) = LazyRWS.RWST $ \r s -> retcon f $ m r s+    chronicle = lift . chronicle++instance (Monoid w, MonadChronicle c m) => MonadChronicle c (StrictRWS.RWST r w s m) where+    dictate = lift . dictate+    confess = lift . confess+    memento (StrictRWS.RWST m) = StrictRWS.RWST $ \r s ->+        either (\c -> (Left c, s, mempty)) (\(a, s', w) -> (Right a, s', w)) `liftM` memento (m r s)+    absolve x (StrictRWS.RWST m) = StrictRWS.RWST $ \r s -> absolve (x, s, mempty) $ m r s+    condemn (StrictRWS.RWST m) = StrictRWS.RWST $ \r s -> condemn $ m r s+    retcon f (StrictRWS.RWST m) = StrictRWS.RWST $ \r s -> retcon f $ m r s     chronicle = lift . chronicle  
Data/Align.hs view
@@ -10,6 +10,7 @@                   , malign, padZip, padZipWith                   , lpadZip, lpadZipWith                   , rpadZip, rpadZipWith+                  , alignVectorWith                                      -- * Unalign                   , Unalign(..)@@ -19,7 +20,6 @@                                      -- * Bicrosswalk                   , Bicrosswalk(..)-                  , alignVectorWith                   ) where  -- TODO: More instances..
these.cabal view
@@ -1,5 +1,5 @@ Name:                these-Version:             0.2+Version:             0.3 Synopsis:            An either-or-both data type, with corresponding hybrid error/writer monad transformer. Homepage:            https://github.com/isomorphism/these License:             BSD3