comonad 4.2.7.2 → 4.3
raw patch · 8 files changed
+39/−74 lines, 8 filesdep ~basedep ~taggeddep ~transformers
Dependency ranges changed: base, tagged, transformers
Files
- .travis.yml +1/−1
- CHANGELOG.markdown +8/−0
- README.markdown +1/−1
- comonad.cabal +3/−4
- src/Control/Comonad.hs +15/−1
- src/Control/Comonad/Trans/Env.hs +10/−0
- src/Control/Comonad/Trans/Traced.hs +1/−1
- src/Data/Functor/Coproduct.hs +0/−66
.travis.yml view
@@ -5,7 +5,7 @@ - GHCVER=7.4.2 CABALVER=1.16 - GHCVER=7.6.3 CABALVER=1.16 - GHCVER=7.8.4 CABALVER=1.18- - GHCVER=7.10.1 CABALVER=1.22+ - GHCVER=7.10.2 CABALVER=1.22 - GHCVER=head CABALVER=1.22 matrix:
CHANGELOG.markdown view
@@ -1,3 +1,11 @@+4.3+-------+* Removed module `Data.Functor.Coproduct` in favor of the `transformers`+ package's `Data.Functor.Sum`. n.b. Compatibility with older versions of+ `transformers` is possible using `transformers-compat`.++* Add `Comonad` instance for `Data.Functor.Sum.Sum`+ 4.2.7.2 ------- * Compiles warning-free on GHC 7.10
README.markdown view
@@ -1,7 +1,7 @@ comonad ======= -[](http://travis-ci.org/ekmett/comonad)+[](https://hackage.haskell.org/package/comonad) [](http://travis-ci.org/ekmett/comonad) This package provides comonads, the categorical dual of monads.
comonad.cabal view
@@ -1,6 +1,6 @@ name: comonad category: Control, Comonads-version: 4.2.7.2+version: 4.3 license: BSD3 cabal-version: >= 1.10 license-file: LICENSE@@ -14,7 +14,7 @@ synopsis: Comonads description: Comonads build-type: Custom-tested-with: GHC==7.0.1, GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.1+tested-with: GHC==7.0.1, GHC == 7.0.4, GHC == 7.2.2, GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.2 extra-source-files: .ghci .gitignore@@ -75,7 +75,7 @@ base >= 4 && < 5, semigroups >= 0.8.3.1 && < 1, tagged >= 0.1 && < 1,- transformers >= 0.2 && < 0.5,+ transformers >= 0.2 && < 0.6, transformers-compat >= 0.3 && < 1 if flag(containers)@@ -103,7 +103,6 @@ Control.Comonad.Trans.Store Control.Comonad.Trans.Traced Data.Functor.Composition- Data.Functor.Coproduct other-extensions: CPP
src/Control/Comonad.hs view
@@ -53,6 +53,7 @@ #endif import Control.Monad.Trans.Identity import Data.Functor.Identity+import qualified Data.Functor.Sum as FSum import Data.List.NonEmpty hiding (map) import Data.Semigroup hiding (Product) import Data.Tagged@@ -200,6 +201,19 @@ extract ~(a :| _) = a {-# INLINE extract #-} +coproduct :: (f a -> b) -> (g a -> b) -> FSum.Sum f g a -> b+coproduct f _ (FSum.InL x) = f x+coproduct _ g (FSum.InR y) = g y+{-# INLINE coproduct #-}++instance (Comonad f, Comonad g) => Comonad (FSum.Sum f g) where+ extend f = coproduct+ (FSum.InL . extend (f . FSum.InL))+ (FSum.InR . extend (f . FSum.InR))+ extract = coproduct extract extract+ {-# INLINE extract #-}++ -- | @ComonadApply@ is to @Comonad@ like @Applicative@ is to @Monad@. -- -- Mathematically, it is a strong lax symmetric semi-monoidal comonad on the@@ -385,7 +399,7 @@ Cokleisli f <*> Cokleisli a = Cokleisli (\w -> f w (a w)) instance Monad (Cokleisli w a) where- return = Cokleisli . const+ return = pure Cokleisli k >>= f = Cokleisli $ \w -> runCokleisli (f (k w)) w #if !(MIN_VERSION_base(4,7,0))
src/Control/Comonad/Trans/Env.hs view
@@ -5,6 +5,9 @@ #elif __GLASGOW_HASKELL__ >= 702 {-# LANGUAGE Trustworthy #-} #endif+#ifndef MIN_VERSION_base+#define MIN_VERSION_base(x,y,z) 1+#endif ----------------------------------------------------------------------------- -- | -- Module : Control.Comonad.Trans.Env@@ -59,6 +62,9 @@ , local ) where +#if !(MIN_VERSION_base(4,8,0))+import Control.Applicative+#endif import Control.Comonad import Control.Comonad.Hoist.Class import Control.Comonad.Trans.Class@@ -146,6 +152,10 @@ instance ComonadTrans (EnvT e) where lower (EnvT _ wa) = wa++instance (Monoid e, Applicative m) => Applicative (EnvT e m) where+ pure = EnvT mempty . pure+ EnvT ef wf <*> EnvT ea wa = EnvT (ef `mappend` ea) (wf <*> wa) -- | Gets rid of the environment. This differs from 'extract' in that it will -- not continue extracting the value from the contained comonad.
src/Control/Comonad/Trans/Traced.hs view
@@ -89,7 +89,7 @@ instance Monoid m => ComonadTrans (TracedT m) where lower = fmap ($ mempty) . runTracedT -instance Monoid m => ComonadHoist (TracedT m) where+instance ComonadHoist (TracedT m) where cohoist l = TracedT . l . runTracedT #ifdef MIN_VERSION_distributive
− src/Data/Functor/Coproduct.hs
@@ -1,66 +0,0 @@-{-# LANGUAGE CPP #-}-#if __GLASGOW_HASKELL__ >= 704-{-# LANGUAGE Safe #-}-#elif __GLASGOW_HASKELL__ >= 702-{-# LANGUAGE Trustworthy #-}-#endif--------------------------------------------------------------------------------- |--- Module : Data.Functor.Coproduct--- Copyright : (C) 2008-2011 Edward Kmett--- License : BSD-style (see the file LICENSE)------ Maintainer : Edward Kmett <ekmett@gmail.com>--- Stability : provisional--- Portability : portable------------------------------------------------------------------------------module Data.Functor.Coproduct- ( Coproduct(..)- , left- , right- , coproduct- ) where--import Control.Comonad-#if __GLASGOW_HASKELL__ < 710-import Data.Foldable-import Data.Traversable-#endif--#ifdef MIN_VERSION_contravariant-import Data.Functor.Contravariant-#endif--newtype Coproduct f g a = Coproduct { getCoproduct :: Either (f a) (g a) }- deriving (Eq, Ord, Read, Show)--left :: f a -> Coproduct f g a-left = Coproduct . Left--right :: g a -> Coproduct f g a-right = Coproduct . Right--coproduct :: (f a -> b) -> (g a -> b) -> Coproduct f g a -> b-coproduct f g = either f g . getCoproduct--instance (Functor f, Functor g) => Functor (Coproduct f g) where- fmap f = Coproduct . coproduct (Left . fmap f) (Right . fmap f)--instance (Foldable f, Foldable g) => Foldable (Coproduct f g) where- foldMap f = coproduct (foldMap f) (foldMap f)--instance (Traversable f, Traversable g) => Traversable (Coproduct f g) where- traverse f = coproduct- (fmap (Coproduct . Left) . traverse f)- (fmap (Coproduct . Right) . traverse f)--instance (Comonad f, Comonad g) => Comonad (Coproduct f g) where- extend f = Coproduct . coproduct- (Left . extend (f . Coproduct . Left))- (Right . extend (f . Coproduct . Right))- extract = coproduct extract extract--#ifdef MIN_VERSION_contravariant-instance (Contravariant f, Contravariant g) => Contravariant (Coproduct f g) where- contramap f = Coproduct . coproduct (Left . contramap f) (Right . contramap f)-#endif