File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ module Data.Functor.Day
3838 ) where
3939
4040import Control.Applicative
41+ import Control.Comonad
4142import Data.Distributive
4243import Data.Functor.Identity
4344import Data.Functor.Rep
@@ -91,6 +92,18 @@ instance (Representable f, Representable g) => Representable (Day f g) where
9192 tabulate f = Day (tabulate id ) (tabulate id ) (curry f)
9293 index (Day m n o) (x,y) = o (index m x) (index n y)
9394
95+ instance (Comonad f , Comonad g ) => Comonad (Day f g ) where
96+ extract (Day fb gc bca) = bca (extract fb) (extract gc)
97+ duplicate (Day fb gc bca) = Day (duplicate fb) (duplicate gc) (\ fb' gc' -> Day fb' gc' bca)
98+
99+ instance (ComonadApply f , ComonadApply g ) => ComonadApply (Day f g ) where
100+ Day fa fb u <@> Day gc gd v =
101+ Day ((,) <$> fa <@> gc) ((,) <$> fb <@> gd)
102+ (\ (a,c) (b,d) -> u a b (v c d))
103+
104+ instance ComonadTrans (Day f ) where
105+ lower (Day fb gc bca) = bca (extract fb) <$> gc
106+
94107-- | Day convolution provides a monoidal product. The associativity
95108-- of this monoid is witnessed by 'assoc' and 'disassoc'.
96109--
You can’t perform that action at this time.
0 commit comments