@@ -1,4 +1,5 @@
11{-# LANGUAGE TypeFamilies #-}
2+{-# LANGUAGE FlexibleInstances #-}
23{-# LANGUAGE ConstraintKinds #-}
34{- |
45Module : Control.Category.Structures
@@ -20,6 +21,7 @@ import Control.Arrow (Kleisli(..))
2021import qualified Control.Arrow as BadArrow
2122import Control.Category
2223import Control.Monad
24+import Data.Semigroupoid.Dual
2325import Prelude hiding (id, (.))
2426
2527infixl 3 ***
@@ -50,6 +52,9 @@ class Category cat => Products cat where
5052instance Monad m => Products (Kleisli m) where
5153 (***) = (BadArrow.***)
5254
55+instance Products cat => Products (Dual cat) where
56+ Dual f *** Dual g = Dual $ f *** g
57+
5358instance Products (->) where
5459 (***) = (BadArrow.***)
5560
@@ -77,6 +82,9 @@ class Category cat => Coproducts cat where
7782instance Monad m => Coproducts (Kleisli m) where
7883 (+++) = (BadArrow.+++)
7984
85+instance Coproducts cat => Coproducts (Dual cat) where
86+ Dual f +++ Dual g = Dual $ f +++ g
87+
8088instance Coproducts (->) where
8189 (+++) = (BadArrow.+++)
8290
@@ -93,6 +101,10 @@ instance MonadPlus m => CatPlus (Kleisli m) where
93101 cempty = BadArrow.zeroArrow
94102 (/+/) = (BadArrow.<+>)
95103
104+instance CatPlus cat => CatPlus (Dual cat) where
105+ cempty = Dual cempty
106+ Dual f /+/ Dual g = Dual $ f /+/ g
107+
96108-- | A category transformer.
97109class CatTrans t where
98110 -- | Lift an arrow from the base category.