monad-supply 0.6 → 0.7
raw patch · 2 files changed
+24/−26 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Control.Monad.Supply: instance (Error e, MonadSupply s m) => MonadSupply s (ErrorT e m)
- Control.Monad.Supply: instance (Monad m, Functor m) => Applicative (SupplyT s m)
- Control.Monad.Supply: instance (Monoid w, MonadSupply s m) => MonadSupply s (WriterT w m)
- Control.Monad.Supply: instance Applicative (Supply s)
- Control.Monad.Supply: instance Functor (Supply s)
- Control.Monad.Supply: instance Functor m => Functor (SupplyT s m)
- Control.Monad.Supply: instance Monad (Supply s)
- Control.Monad.Supply: instance Monad m => Monad (SupplyT s m)
- Control.Monad.Supply: instance Monad m => MonadSupply s (SupplyT s m)
- Control.Monad.Supply: instance MonadFix (Supply s)
- Control.Monad.Supply: instance MonadFix m => MonadFix (SupplyT s m)
- Control.Monad.Supply: instance MonadIO m => MonadIO (SupplyT s m)
- Control.Monad.Supply: instance MonadSupply s (Supply s)
- Control.Monad.Supply: instance MonadSupply s m => MonadSupply s (ReaderT r m)
- Control.Monad.Supply: instance MonadSupply s m => MonadSupply s (StateT st m)
- Control.Monad.Supply: instance MonadTrans (SupplyT s)
- Control.Monad.Supply: instance Monoid a => Monoid (Supply s a)
+ Control.Monad.Supply: instance (Data.Semigroup.Semigroup a, GHC.Base.Monoid a) => GHC.Base.Monoid (Control.Monad.Supply.Supply s a)
+ Control.Monad.Supply: instance (GHC.Base.Monoid w, Control.Monad.Supply.MonadSupply s m) => Control.Monad.Supply.MonadSupply s (Control.Monad.Trans.Writer.Lazy.WriterT w m)
+ Control.Monad.Supply: instance Control.Monad.Fix.MonadFix (Control.Monad.Supply.Supply s)
+ Control.Monad.Supply: instance Control.Monad.Fix.MonadFix m => Control.Monad.Fix.MonadFix (Control.Monad.Supply.SupplyT s m)
+ Control.Monad.Supply: instance Control.Monad.IO.Class.MonadIO m => Control.Monad.IO.Class.MonadIO (Control.Monad.Supply.SupplyT s m)
+ Control.Monad.Supply: instance Control.Monad.Supply.MonadSupply s (Control.Monad.Supply.Supply s)
+ Control.Monad.Supply: instance Control.Monad.Supply.MonadSupply s m => Control.Monad.Supply.MonadSupply s (Control.Monad.Trans.Except.ExceptT e m)
+ Control.Monad.Supply: instance Control.Monad.Supply.MonadSupply s m => Control.Monad.Supply.MonadSupply s (Control.Monad.Trans.Reader.ReaderT r m)
+ Control.Monad.Supply: instance Control.Monad.Supply.MonadSupply s m => Control.Monad.Supply.MonadSupply s (Control.Monad.Trans.State.Lazy.StateT st m)
+ Control.Monad.Supply: instance Control.Monad.Trans.Class.MonadTrans (Control.Monad.Supply.SupplyT s)
+ Control.Monad.Supply: instance Data.Semigroup.Semigroup a => Data.Semigroup.Semigroup (Control.Monad.Supply.Supply s a)
+ Control.Monad.Supply: instance GHC.Base.Applicative (Control.Monad.Supply.Supply s)
+ Control.Monad.Supply: instance GHC.Base.Functor (Control.Monad.Supply.Supply s)
+ Control.Monad.Supply: instance GHC.Base.Functor m => GHC.Base.Functor (Control.Monad.Supply.SupplyT s m)
+ Control.Monad.Supply: instance GHC.Base.Monad (Control.Monad.Supply.Supply s)
+ Control.Monad.Supply: instance GHC.Base.Monad m => Control.Monad.Supply.MonadSupply s (Control.Monad.Supply.SupplyT s m)
+ Control.Monad.Supply: instance GHC.Base.Monad m => GHC.Base.Applicative (Control.Monad.Supply.SupplyT s m)
+ Control.Monad.Supply: instance GHC.Base.Monad m => GHC.Base.Monad (Control.Monad.Supply.SupplyT s m)
Files
- monad-supply.cabal +6/−5
- src/Control/Monad/Supply.hs +18/−21
monad-supply.cabal view
@@ -1,21 +1,22 @@ Name: monad-supply Build-type: Simple-Version: 0.6+Version: 0.7 Cabal-Version: >= 1.6 Synopsis: Stateful supply monad. Description: Support for computations which consume values from a (possibly infinite) supply.-License: OtherLicense+License: MIT License-file: LICENSE Category: Control, Data, Monads Author: Geoff Hulette and unknown HaskellWiki contributor(s).-Maintainer: Geoff Hulette <ghulette@gmail.com>+Maintainer: Geoff Hulette <geoff@hulette.net> Stability: experimental-Tested-With: GHC == 7.0.3+Tested-With: GHC == 8.2.2 Library Exposed-modules: Control.Monad.Supply Hs-Source-Dirs: src- Build-Depends: base >= 4 && < 5,mtl >= 2+ Build-Depends: base >= 4 && < 5,+ mtl >= 2 GHC-Options: -Wall Source-Repository head
src/Control/Monad/Supply.hs view
@@ -1,12 +1,13 @@-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE FunctionalDependencies #-}-{-# LANGUAGE UndecidableInstances #-}+{-# LANGUAGE CPP #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE UndecidableInstances #-} -- | Support for computations which consume values from a (possibly infinite) -- supply. See <http://www.haskell.org/haskellwiki/New_monads/MonadSupply> for -- details.+ module Control.Monad.Supply ( MonadSupply (..) , SupplyT@@ -18,12 +19,12 @@ , supplies ) where -import Control.Applicative-import Control.Monad.Identity-import Control.Monad.State-import Control.Monad.Error-import Control.Monad.Reader-import Control.Monad.Writer+import Control.Monad.Except+import Control.Monad.Identity+import Control.Monad.Reader+import Control.Monad.State+import Control.Monad.Writer hiding ((<>))+import Data.Semigroup class Monad m => MonadSupply s m | m -> s where supply :: m s@@ -34,7 +35,7 @@ newtype SupplyT s m a = SupplyT (StateT [s] m a) deriving (Functor, Applicative, Monad, MonadTrans, MonadIO, MonadFix) --- | Supply monad. +-- | Supply monad. newtype Supply s a = Supply (SupplyT s Identity a) deriving (Functor, Applicative, Monad, MonadSupply s, MonadFix) @@ -46,7 +47,7 @@ exhausted = SupplyT $ gets null -- Monad transformer instances-instance (Error e,MonadSupply s m) => MonadSupply s (ErrorT e m) where+instance (MonadSupply s m) => MonadSupply s (ExceptT e m) where supply = lift supply peek = lift peek exhausted = lift exhausted@@ -66,16 +67,12 @@ peek = lift peek exhausted = lift exhausted --- | Monoid instance for the supply monad. Actually any monad/monoid pair--- gives rise to this monoid instance, but we can't write its type like that--- because it would conflict with existing instances provided by Data.Monoid.---instance (Monoid a, Monad m) => Monoid (m a) where-instance (Monoid a) => Monoid (Supply s a) where+instance Semigroup a => Semigroup (Supply s a) where+ m1 <> m2 = (<>) <$> m1 <*> m2++instance (Semigroup a, Monoid a) => Monoid (Supply s a) where mempty = return mempty- m1 `mappend` m2 = do- x1 <- m1- x2 <- m2- return (x1 `mappend` x2)+ m1 `mappend` m2 = m1 <> m2 -- | Get n supplies. supplies :: MonadSupply s m => Int -> m [s]