From 99b43ddbdbbe0191009ed9895d984e68f2471b51 Mon Sep 17 00:00:00 2001 From: solomon Date: Wed, 17 Jan 2024 09:02:13 -0800 Subject: [PATCH] Adds missing combine operators. --- src/Data/Bifunctor/Monoidal.hs | 38 +++++++- src/Data/Trifunctor/Monoidal.hs | 150 +++++++++++++++++++++++++++++++- 2 files changed, 181 insertions(+), 7 deletions(-) diff --git a/src/Data/Bifunctor/Monoidal.hs b/src/Data/Bifunctor/Monoidal.hs index 1b11df5..65dd7f4 100644 --- a/src/Data/Bifunctor/Monoidal.hs +++ b/src/Data/Bifunctor/Monoidal.hs @@ -3,9 +3,14 @@ module Data.Bifunctor.Monoidal Semigroupal (..), (|??|), (|**|), + (|*+|), + (|*&|), (|++|), - (|&&|), (|+*|), + (|+&|), + (|&&|), + (|&*|), + (|&+|), -- * Unital Unital (..), @@ -268,20 +273,45 @@ infixr 9 |**| (|**|) :: (Semigroupal (->) (,) (,) (,) p) => p a b -> p a' b' -> p (a, a') (b, b') (|**|) = curry combine +infixr 9 |*+| + +(|*+|) :: (Semigroupal (->) (,) Either (,) p) => p a b -> p a' b' -> p (a, a') (Either b b') +(|*+|) = curry combine + +infixr 9 |*&| + +(|*&|) :: (Semigroupal (->) (,) These (,) p) => p a b -> p a' b' -> p (a, a') (These b b') +(|*&|) = curry combine + infixr 9 |++| (|++|) :: (Semigroupal (->) Either Either (,) p) => p a b -> p a' b' -> p (Either a a') (Either b b') (|++|) = curry combine +infixr 9 |+*| + +(|+*|) :: (Semigroupal (->) Either (,) (,) p) => p a b -> p a' b' -> p (Either a a') (b, b') +(|+*|) = curry combine + +infixr 9 |+&| + +(|+&|) :: (Semigroupal (->) These (,) (,) p) => p a b -> p a' b' -> p (These a a') (b, b') +(|+&|) = curry combine + infixr 9 |&&| (|&&|) :: (Semigroupal (->) These These (,) p) => p a b -> p a' b' -> p (These a a') (These b b') (|&&|) = curry combine -infixr 9 |+*| +infixr 9 |&*| -(|+*|) :: (Semigroupal (->) Either (,) (,) p) => p a b -> p a' b' -> p (Either a a') (b, b') -(|+*|) = curry combine +(|&*|) :: (Semigroupal (->) These (,) (,) p) => p a b -> p a' b' -> p (These a a') (b, b') +(|&*|) = curry combine + +infixr 9 |&+| + +(|&+|) :: (Semigroupal (->) These Either (,) p) => p a b -> p a' b' -> p (These a a') (Either b b') +(|&+|) = curry combine -------------------------------------------------------------------------------- diff --git a/src/Data/Trifunctor/Monoidal.hs b/src/Data/Trifunctor/Monoidal.hs index e45f131..c6f906b 100644 --- a/src/Data/Trifunctor/Monoidal.hs +++ b/src/Data/Trifunctor/Monoidal.hs @@ -1,9 +1,33 @@ module Data.Trifunctor.Monoidal ( -- * Semigroupal Semigroupal (..), + (|???|), (|***|), + (|**+|), + (|**&|), (|*+*|), + (|*++|), + (|*+&|), + (|*&*|), + (|*&+|), + (|*&&|), + (|+**|), + (|+*+|), + (|+*&|), + (|++*|), (|+++|), + (|++&|), + (|+&*|), + (|+&+|), + (|+&&|), + (|&**|), + (|&*+|), + (|&*&|), + (|&+*|), + (|&++|), + (|&+&|), + (|&&*|), + (|&&+|), (|&&&|), -- * Unital @@ -55,21 +79,141 @@ class -- | A natural transformation \(\phi_{ABC,XYZ} : F\ A\ B\ C \bullet F\ X\ Y\ Z \to F\ (A \otimes X)\ (B \otimes Y) (C \otimes Z)\). combine :: to (f x y z) (f x' y' z') `cat` f (t1 x x') (t2 y y') (t3 z z') -infixr 9 |*+*| +infixr 9 |???| -(|*+*|) :: (Semigroupal (->) (,) Either (,) (,) p) => p a b c -> p a' b c' -> p (a, a') (Either b b) (c, c') -(|*+*|) = curry combine +(|???|) :: (Semigroupal (->) t1 t2 t3 (,) p) => p a b c -> p a' b' c' -> p (a `t1` a') (b `t2` b') (c `t3` c') +(|???|) = curry combine infixr 9 |***| (|***|) :: (Semigroupal (->) (,) (,) (,) (,) p) => p a b c -> p a' b' c' -> p (a, a') (b, b') (c, c') (|***|) = curry combine +infixr 9 |**+| + +(|**+|) :: (Semigroupal (->) (,) (,) Either (,) p) => p a b c -> p a' b' c' -> p (a, a') (b, b') (Either c c') +(|**+|) = curry combine + +infixr 9 |**&| + +(|**&|) :: (Semigroupal (->) (,) (,) These (,) p) => p a b c -> p a' b' c' -> p (a, a') (b, b') (These c c') +(|**&|) = curry combine + +infixr 9 |*+*| + +(|*+*|) :: (Semigroupal (->) (,) Either (,) (,) p) => p a b c -> p a' b c' -> p (a, a') (Either b b) (c, c') +(|*+*|) = curry combine + +infixr 9 |*++| + +(|*++|) :: (Semigroupal (->) (,) Either Either (,) p) => p a b c -> p a' b c' -> p (a, a') (Either b b) (Either c c') +(|*++|) = curry combine + +infixr 9 |*+&| + +(|*+&|) :: (Semigroupal (->) (,) Either These (,) p) => p a b c -> p a' b c' -> p (a, a') (Either b b) (These c c') +(|*+&|) = curry combine + +infixr 9 |*&*| + +(|*&*|) :: (Semigroupal (->) (,) These (,) (,) p) => p a b c -> p a' b c' -> p (a, a') (These b b) (c, c') +(|*&*|) = curry combine + +infixr 9 |*&+| + +(|*&+|) :: (Semigroupal (->) (,) These Either (,) p) => p a b c -> p a' b c' -> p (a, a') (These b b) (Either c c') +(|*&+|) = curry combine + +infixr 9 |*&&| + +(|*&&|) :: (Semigroupal (->) (,) These These (,) p) => p a b c -> p a' b' c' -> p (a, a') (These b b') (These c c') +(|*&&|) = curry combine + +infixr 9 |+**| + +(|+**|) :: (Semigroupal (->) Either (,) (,) (,) p) => p a b c -> p a' b c' -> p (Either a a') (b, b) (c, c') +(|+**|) = curry combine + +infixr 9 |+*+| + +(|+*+|) :: (Semigroupal (->) Either (,) Either (,) p) => p a b c -> p a' b c' -> p (Either a a') (b, b) (Either c c') +(|+*+|) = curry combine + +infixr 9 |+*&| + +(|+*&|) :: (Semigroupal (->) Either (,) These (,) p) => p a b c -> p a' b c' -> p (Either a a') (b, b) (These c c') +(|+*&|) = curry combine + +infixr 9 |++*| + +(|++*|) :: (Semigroupal (->) Either Either (,) (,) p) => p a b c -> p a' b c' -> p (Either a a') (Either b b) (c, c') +(|++*|) = curry combine + infixr 9 |+++| (|+++|) :: (Semigroupal (->) Either Either Either (,) p) => p a b c -> p a' b' c' -> p (Either a a') (Either b b') (Either c c') (|+++|) = curry combine +infixr 9 |++&| + +(|++&|) :: (Semigroupal (->) Either Either These (,) p) => p a b c -> p a' b c' -> p (Either a a') (Either b b) (These c c') +(|++&|) = curry combine + +infixr 9 |+&*| + +(|+&*|) :: (Semigroupal (->) Either These (,) (,) p) => p a b c -> p a' b c' -> p (Either a a') (These b b) (c, c') +(|+&*|) = curry combine + +infixr 9 |+&+| + +(|+&+|) :: (Semigroupal (->) Either These Either (,) p) => p a b c -> p a' b c' -> p (Either a a') (These b b) (Either c c') +(|+&+|) = curry combine + +infixr 9 |+&&| + +(|+&&|) :: (Semigroupal (->) Either These These (,) p) => p a b c -> p a' b' c' -> p (Either a a') (These b b') (These c c') +(|+&&|) = curry combine + +infixr 9 |&**| + +(|&**|) :: (Semigroupal (->) These (,) (,) (,) p) => p a b c -> p a' b' c' -> p (These a a') (b, b') (c, c') +(|&**|) = curry combine + +infixr 9 |&*+| + +(|&*+|) :: (Semigroupal (->) These (,) Either (,) p) => p a b c -> p a' b' c' -> p (These a a') (b, b') (Either c c') +(|&*+|) = curry combine + +infixr 9 |&*&| + +(|&*&|) :: (Semigroupal (->) These (,) These (,) p) => p a b c -> p a' b' c' -> p (These a a') (b, b') (These c c') +(|&*&|) = curry combine + +infixr 9 |&+*| + +(|&+*|) :: (Semigroupal (->) These Either (,) (,) p) => p a b c -> p a' b' c' -> p (These a a') (Either b b') (c, c') +(|&+*|) = curry combine + +infixr 9 |&++| + +(|&++|) :: (Semigroupal (->) These Either Either (,) p) => p a b c -> p a' b' c' -> p (These a a') (Either b b') (Either c c') +(|&++|) = curry combine + +infixr 9 |&+&| + +(|&+&|) :: (Semigroupal (->) These Either These (,) p) => p a b c -> p a' b' c' -> p (These a a') (Either b b') (These c c') +(|&+&|) = curry combine + +infixr 9 |&&*| + +(|&&*|) :: (Semigroupal (->) These These (,) (,) p) => p a b c -> p a' b' c' -> p (These a a') (These b b') (c, c') +(|&&*|) = curry combine + +infixr 9 |&&+| + +(|&&+|) :: (Semigroupal (->) These These Either (,) p) => p a b c -> p a' b' c' -> p (These a a') (These b b') (Either c c') +(|&&+|) = curry combine + infixr 9 |&&&| (|&&&|) :: (Semigroupal (->) These These These (,) p) => p a b c -> p a' b' c' -> p (These a a') (These b b') (These c c')