summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorryanglscott <>2019-11-26 14:08:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-11-26 14:08:00 (GMT)
commit724838593bf554f014043beb989aa184f4585628 (patch)
treef513683e3ec81b2836d63fba96eed482ca8119de
parent50cb16053254eb3e95e8c3760389519328a1b1da (diff)
version 5.5.15.5.1
-rwxr-xr-xCHANGELOG.markdown5
-rw-r--r--profunctors.cabal2
-rw-r--r--src/Data/Profunctor/Choice.hs17
-rw-r--r--src/Data/Profunctor/Closed.hs7
-rw-r--r--src/Data/Profunctor/Strong.hs17
5 files changed, 44 insertions, 4 deletions
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index 16cdf41..de81dd0 100755
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -1,3 +1,8 @@
+5.5.1 [2019.11.26]
+------------------
+* Add `Choice`, `Cochoice`, `Closed`, `Strong`, and `Costrong` instances for
+ `Data.Bifunctor.Sum`.
+
5.5 [2019.09.06]
----------------
* Change the type of `roam` to make it actually useful.
diff --git a/profunctors.cabal b/profunctors.cabal
index c7aa41a..21b1fd7 100644
--- a/profunctors.cabal
+++ b/profunctors.cabal
@@ -1,6 +1,6 @@
name: profunctors
category: Control, Categories
-version: 5.5
+version: 5.5.1
license: BSD3
cabal-version: >= 1.10
license-file: LICENSE
diff --git a/src/Data/Profunctor/Choice.hs b/src/Data/Profunctor/Choice.hs
index 9b865ed..edae1bf 100644
--- a/src/Data/Profunctor/Choice.hs
+++ b/src/Data/Profunctor/Choice.hs
@@ -33,8 +33,9 @@ import Control.Category
import Control.Comonad
import Data.Bifunctor.Joker (Joker(..))
import Data.Bifunctor.Product (Product(..))
+import Data.Bifunctor.Sum (Sum(..))
import Data.Bifunctor.Tannen (Tannen(..))
-import Data.Monoid hiding (Product)
+import Data.Monoid hiding (Product, Sum)
import Data.Profunctor.Adjunction
import Data.Profunctor.Monad
import Data.Profunctor.Strong
@@ -158,6 +159,14 @@ instance (Choice p, Choice q) => Choice (Product p q) where
right' (Pair p q) = Pair (right' p) (right' q)
{-# INLINE right' #-}
+instance (Choice p, Choice q) => Choice (Sum p q) where
+ left' (L2 p) = L2 (left' p)
+ left' (R2 q) = R2 (left' q)
+ {-# INLINE left' #-}
+ right' (L2 p) = L2 (right' p)
+ right' (R2 q) = R2 (right' q)
+ {-# INLINE right' #-}
+
instance (Functor f, Choice p) => Choice (Tannen f p) where
left' (Tannen fp) = Tannen (fmap left' fp)
{-# INLINE left' #-}
@@ -349,6 +358,12 @@ instance (Cochoice p, Cochoice q) => Cochoice (Product p q) where
unleft (Pair p q) = Pair (unleft p) (unleft q)
unright (Pair p q) = Pair (unright p) (unright q)
+instance (Cochoice p, Cochoice q) => Cochoice (Sum p q) where
+ unleft (L2 p) = L2 (unleft p)
+ unleft (R2 q) = R2 (unleft q)
+ unright (L2 p) = L2 (unright p)
+ unright (R2 q) = R2 (unright q)
+
instance Cochoice (Forget r) where
unleft (Forget f) = Forget (f . Left)
unright (Forget f) = Forget (f . Right)
diff --git a/src/Data/Profunctor/Closed.hs b/src/Data/Profunctor/Closed.hs
index 9e3baed..a16f856 100644
--- a/src/Data/Profunctor/Closed.hs
+++ b/src/Data/Profunctor/Closed.hs
@@ -30,6 +30,7 @@ import Control.Arrow
import Control.Category
import Control.Comonad
import Data.Bifunctor.Product (Product(..))
+import Data.Bifunctor.Sum (Sum(..))
import Data.Bifunctor.Tannen (Tannen(..))
import Data.Coerce (Coercible, coerce)
import Data.Distributive
@@ -38,7 +39,7 @@ import Data.Profunctor.Monad
import Data.Profunctor.Strong
import Data.Profunctor.Types
import Data.Profunctor.Unsafe
-import Data.Semigroup hiding (Product)
+import Data.Semigroup hiding (Product, Sum)
import Data.Tagged
import Data.Tuple
import Prelude hiding ((.),id)
@@ -81,6 +82,10 @@ instance (Distributive f, Monad f) => Closed (Kleisli f) where
instance (Closed p, Closed q) => Closed (Product p q) where
closed (Pair p q) = Pair (closed p) (closed q)
+instance (Closed p, Closed q) => Closed (Sum p q) where
+ closed (L2 p) = L2 (closed p)
+ closed (R2 q) = R2 (closed q)
+
instance (Functor f, Closed p) => Closed (Tannen f p) where
closed (Tannen fp) = Tannen (fmap closed fp)
diff --git a/src/Data/Profunctor/Strong.hs b/src/Data/Profunctor/Strong.hs
index b777e43..719ccbd 100644
--- a/src/Data/Profunctor/Strong.hs
+++ b/src/Data/Profunctor/Strong.hs
@@ -39,13 +39,14 @@ import Control.Monad (liftM)
import Control.Monad.Fix
import Data.Bifunctor.Clown (Clown(..))
import Data.Bifunctor.Product (Product(..))
+import Data.Bifunctor.Sum (Sum(..))
import Data.Bifunctor.Tannen (Tannen(..))
import Data.Functor.Contravariant (Contravariant(..))
import Data.Profunctor.Adjunction
import Data.Profunctor.Monad
import Data.Profunctor.Types
import Data.Profunctor.Unsafe
-import Data.Semigroup hiding (Product)
+import Data.Semigroup hiding (Product, Sum)
import Data.Tagged
import Data.Tuple
import Prelude hiding (id,(.))
@@ -146,6 +147,14 @@ instance (Strong p, Strong q) => Strong (Product p q) where
second' (Pair p q) = Pair (second' p) (second' q)
{-# INLINE second' #-}
+instance (Strong p, Strong q) => Strong (Sum p q) where
+ first' (L2 p) = L2 (first' p)
+ first' (R2 q) = R2 (first' q)
+ {-# INLINE first' #-}
+ second' (L2 p) = L2 (second' p)
+ second' (R2 q) = R2 (second' q)
+ {-# INLINE second' #-}
+
instance (Functor f, Strong p) => Strong (Tannen f p) where
first' (Tannen fp) = Tannen (fmap first' fp)
{-# INLINE first' #-}
@@ -378,6 +387,12 @@ instance (Costrong p, Costrong q) => Costrong (Product p q) where
unfirst (Pair p q) = Pair (unfirst p) (unfirst q)
unsecond (Pair p q) = Pair (unsecond p) (unsecond q)
+instance (Costrong p, Costrong q) => Costrong (Sum p q) where
+ unfirst (L2 p) = L2 (unfirst p)
+ unfirst (R2 q) = R2 (unfirst q)
+ unsecond (L2 p) = L2 (unsecond p)
+ unsecond (R2 q) = R2 (unsecond q)
+
----------------------------------------------------------------------------
-- * Cotambara
----------------------------------------------------------------------------