summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorryanglscott <>2020-02-13 19:20:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-02-13 19:20:00 (GMT)
commitc7d9697c5985a76ca91679cc2c69363f75216ef5 (patch)
treec2f11ab5b8244bc8ad89f96c68922eab22b854d8
parent724838593bf554f014043beb989aa184f4585628 (diff)
version 5.5.2HEAD5.5.2master
-rwxr-xr-xCHANGELOG.markdown6
-rw-r--r--profunctors.cabal2
-rw-r--r--src/Data/Profunctor/Cayley.hs20
-rw-r--r--src/Data/Profunctor/Mapping.hs4
-rw-r--r--src/Data/Profunctor/Traversing.hs4
5 files changed, 35 insertions, 1 deletions
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index de81dd0..6db1d59 100755
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -1,3 +1,9 @@
+5.5.2 [2020.02.13]
+------------------
+* Add `Cochoice`, `Costrong`, `Closed`, `Traversing`, and `Mapping` instances
+ for `Cayley`.
+* Add `Mapping` and `Traversing` instances for `Tannen`.
+
5.5.1 [2019.11.26]
------------------
* Add `Choice`, `Cochoice`, `Closed`, `Strong`, and `Costrong` instances for
diff --git a/profunctors.cabal b/profunctors.cabal
index 21b1fd7..c993177 100644
--- a/profunctors.cabal
+++ b/profunctors.cabal
@@ -1,6 +1,6 @@
name: profunctors
category: Control, Categories
-version: 5.5.1
+version: 5.5.2
license: BSD3
cabal-version: >= 1.10
license-file: LICENSE
diff --git a/src/Data/Profunctor/Cayley.hs b/src/Data/Profunctor/Cayley.hs
index 030c51c..24ddd19 100644
--- a/src/Data/Profunctor/Cayley.hs
+++ b/src/Data/Profunctor/Cayley.hs
@@ -19,6 +19,7 @@ import Control.Category
import Control.Comonad
import Data.Profunctor
import Data.Profunctor.Monad
+import Data.Profunctor.Traversing
import Data.Profunctor.Unsafe
import Prelude hiding ((.), id)
@@ -49,10 +50,29 @@ instance (Functor f, Strong p) => Strong (Cayley f p) where
first' = Cayley . fmap first' . runCayley
second' = Cayley . fmap second' . runCayley
+instance (Functor f, Costrong p) => Costrong (Cayley f p) where
+ unfirst (Cayley fp) = Cayley (fmap unfirst fp)
+ unsecond (Cayley fp) = Cayley (fmap unsecond fp)
+
instance (Functor f, Choice p) => Choice (Cayley f p) where
left' = Cayley . fmap left' . runCayley
right' = Cayley . fmap right' . runCayley
+instance (Functor f, Cochoice p) => Cochoice (Cayley f p) where
+ unleft (Cayley fp) = Cayley (fmap unleft fp)
+ {-# INLINE unleft #-}
+ unright (Cayley fp) = Cayley (fmap unright fp)
+ {-# INLINE unright #-}
+
+instance (Functor f, Closed p) => Closed (Cayley f p) where
+ closed = Cayley . fmap closed . runCayley
+
+instance (Functor f, Traversing p) => Traversing (Cayley f p) where
+ traverse' = Cayley . fmap traverse' . runCayley
+
+instance (Functor f, Mapping p) => Mapping (Cayley f p) where
+ map' = Cayley . fmap map' . runCayley
+
instance (Applicative f, Category p) => Category (Cayley f p) where
id = Cayley $ pure id
Cayley fpbc . Cayley fpab = Cayley $ liftA2 (.) fpbc fpab
diff --git a/src/Data/Profunctor/Mapping.hs b/src/Data/Profunctor/Mapping.hs
index ac903bb..7538fee 100644
--- a/src/Data/Profunctor/Mapping.hs
+++ b/src/Data/Profunctor/Mapping.hs
@@ -24,6 +24,7 @@ module Data.Profunctor.Mapping
) where
import Control.Arrow (Kleisli(..))
+import Data.Bifunctor.Tannen
import Data.Distributive
import Data.Functor.Compose
import Data.Functor.Identity
@@ -90,6 +91,9 @@ instance (Applicative m, Distributive m) => Mapping (Star m) where
map' (Star f) = Star (collect f)
roam f = Star #. genMap f .# runStar
+instance (Functor f, Mapping p) => Mapping (Tannen f p) where
+ map' = Tannen . fmap map' . runTannen
+
wanderMapping :: Mapping p => (forall f. Applicative f => (a -> f b) -> s -> f t) -> p a b -> p s t
wanderMapping f = roam ((runIdentity .) #. f .# (Identity .))
diff --git a/src/Data/Profunctor/Traversing.hs b/src/Data/Profunctor/Traversing.hs
index 2bd0c5a..99edff5 100644
--- a/src/Data/Profunctor/Traversing.hs
+++ b/src/Data/Profunctor/Traversing.hs
@@ -20,6 +20,7 @@ module Data.Profunctor.Traversing
import Control.Applicative
import Control.Arrow (Kleisli(..))
+import Data.Bifunctor.Tannen
import Data.Functor.Compose
import Data.Functor.Identity
import Data.Orphans ()
@@ -136,6 +137,9 @@ instance Applicative m => Traversing (Star m) where
traverse' (Star m) = Star (traverse m)
wander f (Star amb) = Star (f amb)
+instance (Functor f, Traversing p) => Traversing (Tannen f p) where
+ traverse' = Tannen . fmap traverse' . runTannen
+
newtype CofreeTraversing p a b = CofreeTraversing { runCofreeTraversing :: forall f. Traversable f => p (f a) (f b) }
instance Profunctor p => Profunctor (CofreeTraversing p) where