free 5.1.4 → 5.1.5
raw patch · 6 files changed
+43/−6 lines, 6 filesdep +indexed-traversablePVP ok
version bump matches the API change (PVP)
Dependencies added: indexed-traversable
API changes (from Hackage documentation)
+ Control.Comonad.Cofree: instance WithIndex.FoldableWithIndex i f => WithIndex.FoldableWithIndex [i] (Control.Comonad.Cofree.Cofree f)
+ Control.Comonad.Cofree: instance WithIndex.FunctorWithIndex i f => WithIndex.FunctorWithIndex [i] (Control.Comonad.Cofree.Cofree f)
+ Control.Comonad.Cofree: instance WithIndex.TraversableWithIndex i f => WithIndex.TraversableWithIndex [i] (Control.Comonad.Cofree.Cofree f)
+ Control.Monad.Free: instance WithIndex.FoldableWithIndex i f => WithIndex.FoldableWithIndex [i] (Control.Monad.Free.Free f)
+ Control.Monad.Free: instance WithIndex.FunctorWithIndex i f => WithIndex.FunctorWithIndex [i] (Control.Monad.Free.Free f)
+ Control.Monad.Free: instance WithIndex.TraversableWithIndex i f => WithIndex.TraversableWithIndex [i] (Control.Monad.Free.Free f)
Files
- .ghci +0/−1
- CHANGELOG.markdown +4/−0
- examples/free-examples.cabal +1/−1
- free.cabal +5/−4
- src/Control/Comonad/Cofree.hs +15/−0
- src/Control/Monad/Free.hs +18/−0
.ghci view
@@ -1,1 +0,0 @@-:set -isrc -idist/build/autogen -optP-include -optPdist/build/autogen/cabal_macros.h
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+5.1.5 [2020.12.16]+------------------+* Move `indexed-traversable` (`FunctorWithIndex` etc) instances from `lens`.+ 5.1.4 [2020.10.01] ------------------ * Allow building with `template-haskell-2.17.0.0` (GHC 9.0).
examples/free-examples.cabal view
@@ -2,7 +2,7 @@ category: Control, Monads version: 0.1 license: BSD3-cabal-version: >= 1.18+cabal-version: 1.18 license-file: LICENSE author: Edward A. Kmett maintainer: Edward A. Kmett <ekmett@gmail.com>
free.cabal view
@@ -1,6 +1,6 @@ name: free category: Control, Monads-version: 5.1.4+version: 5.1.5 license: BSD3 cabal-version: 1.18 license-file: LICENSE@@ -83,16 +83,17 @@ build-depends: base == 4.*, comonad >= 4 && < 6,+ containers < 0.7, distributive >= 0.2.1,+ exceptions >= 0.6 && < 0.11,+ indexed-traversable >= 0.1 && < 0.2, mtl >= 2.0.1.0 && < 2.3, profunctors >= 4 && < 6, semigroupoids >= 4 && < 6, th-abstraction >= 0.4 && < 0.5, transformers >= 0.2.0 && < 0.6, transformers-base >= 0.4 && < 0.5,- template-haskell >= 2.7.0.0 && < 2.18,- exceptions >= 0.6 && < 0.11,- containers < 0.7+ template-haskell >= 2.7.0.0 && < 2.18 if !impl(ghc >= 8.2) build-depends: bifunctors >= 4 && < 6
src/Control/Comonad/Cofree.hs view
@@ -54,11 +54,14 @@ import Data.Functor.Bind import Data.Functor.Classes.Compat import Data.Functor.Extend+import Data.Functor.WithIndex import Data.Data import Data.Distributive import Data.Foldable+import Data.Foldable.WithIndex import Data.Semigroup import Data.Traversable+import Data.Traversable.WithIndex import Data.Semigroup.Foldable import Data.Semigroup.Traversable import Prelude hiding (id,(.))@@ -311,6 +314,18 @@ traverse1 f = go where go (a :< as) = (:<) <$> f a <.> traverse1 go as {-# INLINE traverse1 #-}++instance FunctorWithIndex i f => FunctorWithIndex [i] (Cofree f) where+ imap f (a :< as) = f [] a :< imap (\i -> imap (f . (:) i)) as+ {-# INLINE imap #-}++instance FoldableWithIndex i f => FoldableWithIndex [i] (Cofree f) where+ ifoldMap f (a :< as) = f [] a `mappend` ifoldMap (\i -> ifoldMap (f . (:) i)) as+ {-# INLINE ifoldMap #-}++instance TraversableWithIndex i f => TraversableWithIndex [i] (Cofree f) where+ itraverse f (a :< as) = (:<) <$> f [] a <*> itraverse (\i -> itraverse (f . (:) i)) as+ {-# INLINE itraverse #-} #if __GLASGOW_HASKELL__ < 707 instance (Typeable1 f) => Typeable1 (Cofree f) where
src/Control/Monad/Free.hs view
@@ -52,9 +52,12 @@ import Control.Monad.Cont.Class import Data.Functor.Bind import Data.Functor.Classes.Compat+import Data.Functor.WithIndex import Data.Foldable+import Data.Foldable.WithIndex import Data.Profunctor import Data.Traversable+import Data.Traversable.WithIndex import Data.Semigroup.Foldable import Data.Semigroup.Traversable import Data.Data@@ -294,6 +297,21 @@ go (Pure a) = Pure <$> f a go (Free fa) = Free <$> traverse1 go fa {-# INLINE traverse1 #-}++instance FunctorWithIndex i f => FunctorWithIndex [i] (Free f) where+ imap f (Pure a) = Pure $ f [] a+ imap f (Free s) = Free $ imap (\i -> imap (f . (:) i)) s+ {-# INLINE imap #-}++instance FoldableWithIndex i f => FoldableWithIndex [i] (Free f) where+ ifoldMap f (Pure a) = f [] a+ ifoldMap f (Free s) = ifoldMap (\i -> ifoldMap (f . (:) i)) s+ {-# INLINE ifoldMap #-}++instance TraversableWithIndex i f => TraversableWithIndex [i] (Free f) where+ itraverse f (Pure a) = Pure <$> f [] a+ itraverse f (Free s) = Free <$> itraverse (\i -> itraverse (f . (:) i)) s+ {-# INLINE itraverse #-} instance (Functor m, MonadWriter e m) => MonadWriter e (Free m) where tell = lift . tell