0 | module Data.Container.Base.Monoid.Definition
2 | import public Data.List.Quantifiers
4 | import Data.Container.Base.Object.Definition
5 | import Data.Container.Base.Morphism.Definition
6 | import Data.Container.Base.Extension.Definition
7 | import Data.Container.Base.Product.Definition
11 | import Data.Container.Base.Object.Instances
17 | interface TensorMonoid (0 c : Cont) where
18 | tensorN : Scalar =%> c
19 | tensorM : c >< c =%> c
22 | interface TensorComonoid (0 c : Cont) where
23 | tensorCounit : c =%> Scalar
24 | tensorComult : c =%> c >< c
29 | interface TensorMonoid c => SeqMonoid (0 c : Cont) where
35 | interface TensorComonoid c => SeqComonoid (0 c : Cont) where
36 | seqComult : c =%> c >@ c
39 | interface CoprodMonoid (0 c : Cont) where
41 | plusM : c >+< c =%> c
45 | interface ProdMonoid (0 c : Cont) where
46 | prodN : UnitCont =%> c
47 | prodM : c >*< c =%> c
50 | liftA2Ext : TensorMonoid c => Ext c a -> Ext c b -> Ext c (a, b)
51 | liftA2Ext aExt bExt = extMap tensorM $
pairExtensions aExt bExt
54 | TensorMonoid c => Applicative (Ext c) where
55 | pure x = tensorN.fwd () <| const x
56 | fExt <*> aExt = uncurry ($) <$> liftA2Ext fExt aExt
59 | [FromSeq] SeqMonoid c => Applicative (Ext c) where
60 | pure x = tensorN.fwd () <| const x
61 | (f <| f') <*> (x <| x') = ?notAThing
64 | SeqMonoid c => Monad (Ext c) using FromSeq where
65 | join (a <| b) = let (
q1 ** q2)
= (%! seqM) (a <| shapeExt . b)
66 | in q1 <| ((\xx => (b xx.fst).index xx.snd) . q2)
69 | [FromProd] ProdMonoid c => Applicative (Ext c) where
70 | pure x = prodN.fwd () <| const x
74 | ProdMonoid c => Alternative (Ext c) using FromProd where
75 | empty = let (
p1 ** p2)
= (%! prodN) () in p1 <| absurd . p2
76 | (<|>) (a <| a') (b <| b') =
77 | let (
m1 ** m2)
= (%! prodM) (a, b) in m1 <| either a' b' . m2