0 | module Data.Container.Base.Endofunctor.Definition
2 | import Data.List.Quantifiers
3 | import Decidable.Equality
5 | import Data.Container.Base.Object.Definition
6 | import Data.Container.Base.Morphism.Definition
7 | import Data.Container.Base.Properties.Definition
9 | import Data.ComMonoid
21 | public export infixr 9 <!>
22 | public export prefix 9 !!
23 | public export prefix 9 !*
27 | (<!>) : (f : Type -> Type) -> Cont -> Cont
28 | f <!> c = (s : c.Shp) !> f (c.Pos s)
32 | (<!>) : (f : Type -> Type) -> Functor f =>
35 | f <!> l = !% \x => let (
y ** ky)
= (%!) l x
52 | (!!) : c =%> d -> !! c =%> !! d
56 | (!*) : c =%> d -> !* c =%> !* d
64 | pureBw : Monad m => m <!> c =%> c
65 | pureBw = !% \x => (
x ** pure)
68 | joinBw : Monad m => m <!> c =%> m <!> (m <!> c)
69 | joinBw = !% \x => (
x ** join)
75 | sumBw : InterfaceOnPositions c ComMonoid => c =%> Bag <!> c
76 | sumBw @{MkI i} = !% \x => (
x ** sum @{i x})
81 | namespace FunctorsOnCont
83 | ListAll : Cont -> Cont
84 | ListAll c = (ss : List c.Shp) !> All c.Pos ss
87 | ListAny : Cont -> Cont
88 | ListAny c = (ss : List c.Shp) !> Any c.Pos ss
91 | BagAll : Cont -> Cont
92 | BagAll c = (ss : Bag c.Shp) !> All c.Pos ss
95 | unitBag : c =%> BagAll c
96 | unitBag = !% \x => (
MkBag [x] ** qq)
97 | where qq : List.Quantifiers.All.All (c .Pos) [x] -> c .Pos x
102 | bww : (f : c =%> d) -> (cs : List c.Shp) ->
103 | All (d.Pos) (f.fwd <$> cs) -> All (c .Pos) cs
105 | bww f (c :: cs) (a :: as) = (f.bwd c a) :: bww f cs as
108 | List : c =%> d -> ListAll c =%> ListAll d
109 | List f = !% \cs => (
f.fwd <$> cs ** bww f cs)
115 | Deriv : (c : Cont) ->
116 | InterfaceOnPositions c DecEq =>
118 | Deriv (shp !> pos) @{MkI _}
119 | = ((
s ** p)
: DPair shp pos) !> (p' : pos s ** IsNo (decEq p p'))