{-# LANGUAGE GADTs, EmptyDataDecls #-}
module Data.Semigroupoid.Coproduct
( L, R, Coproduct(..), distributeDualCoproduct, factorDualCoproduct) where
import Data.Semigroupoid
import Data.Semigroupoid.Dual
import Data.Groupoid
data La
data Radata Coproduct j k a b where
L :: j a b -> Coproduct j k (L a) (L b)
R :: k a b -> Coproduct j k (R a) (R b)
instance (Semigroupoid j, Semigroupoid k) =>Semigroupoid (Coproductjk) where
Lf`o`Lg = L (f`o`g)
Rf`o`Rg = R (f`o`g)
_ `o` _ = error"GADT fail"
instance (Groupoid j, Groupoid k) =>Groupoid (Coproductjk) where
inv (Lf) = L (invf)
inv (Rf) = R (invf)
distributeDualCoproduct :: Dual (Coproductjk) ab -> Coproduct (Dualj) (Dualk) abdistributeDualCoproduct (Dual (Ll)) = L (Duall)
distributeDualCoproduct (Dual (Rr)) = R (Dualr)
factorDualCoproduct :: Coproduct (Dualj) (Dualk) ab -> Dual (Coproductjk) abfactorDualCoproduct (L (Duall)) = Dual (Ll)
factorDualCoproduct (R (Dualr)) = Dual (Rr)