Skip to content

Commit

Permalink
Adds missing combine operators.
Browse files Browse the repository at this point in the history
  • Loading branch information
solomon-b committed Jan 24, 2024
1 parent a58e487 commit 99b43dd
Show file tree
Hide file tree
Showing 2 changed files with 181 additions and 7 deletions.
38 changes: 34 additions & 4 deletions src/Data/Bifunctor/Monoidal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ module Data.Bifunctor.Monoidal
Semigroupal (..),
(|??|),
(|**|),
(|*+|),
(|*&|),
(|++|),
(|&&|),
(|+*|),
(|+&|),
(|&&|),
(|&*|),
(|&+|),

-- * Unital
Unital (..),
Expand Down Expand Up @@ -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

--------------------------------------------------------------------------------

Expand Down
150 changes: 147 additions & 3 deletions src/Data/Trifunctor/Monoidal.hs
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
module Data.Trifunctor.Monoidal
( -- * Semigroupal
Semigroupal (..),
(|???|),
(|***|),
(|**+|),
(|**&|),
(|*+*|),
(|*++|),
(|*+&|),
(|*&*|),
(|*&+|),
(|*&&|),
(|+**|),
(|+*+|),
(|+*&|),
(|++*|),
(|+++|),
(|++&|),
(|+&*|),
(|+&+|),
(|+&&|),
(|&**|),
(|&*+|),
(|&*&|),
(|&+*|),
(|&++|),
(|&+&|),
(|&&*|),
(|&&+|),
(|&&&|),

-- * Unital
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 99b43dd

Please sign in to comment.