0 | module Data.Container.Additive.Morphism.Definition
2 | import Data.Container.Base
3 | import Data.ComMonoid
4 | import Data.Container.Additive.Object.Definition
10 | public export prefix 0 %!
11 | public export prefix 0 &!
12 | public export prefix 0 !%+
13 | public export prefix 0 !&+
14 | export infixl 5 %+>>
15 | export infixl 5 &+>>
17 | namespace DependentLenses
29 | record (=%+>) (c, d : AddCont) where
31 | ULens : UC c =%> UC d
36 | (!%+) : {0 c, d : AddCont} ->
37 | ((x : c.Shp) -> (y : d.Shp ** (d.PosSet y -> c.PosSet x))) ->
39 | (!%+) f = (!%) ((!%) f)
42 | (%!+) : {0 c, d : AddCont} ->
43 | c =%+> d -> (x : c.Shp) -> (y : d.Shp ** (d.PosSet y -> c.PosSet x))
44 | (%!+) (!% f) = (%!) f
47 | (.fwd) : {0 c, d : AddCont} -> c =%+> d -> c.Shp -> d.Shp
48 | (.fwd) f = (ULens f).fwd
51 | (.bwd) : {0 c, d : AddCont} -> (f : c =%+> d) ->
52 | (x : c.Shp) -> d.PosSet (f.fwd x) -> c.PosSet x
53 | (.bwd) f = (ULens f).bwd
56 | compDepLens : {0 c, d, e : AddCont} -> c =%+> d -> d =%+> e -> c =%+> e
57 | compDepLens f g = (!%) (compDepLens (ULens f) (ULens g))
60 | (%+>>) : {0 c, d, e : AddCont} -> c =%+> d -> d =%+> e -> c =%+> e
61 | (%+>>) = compDepLens
64 | id : {0 c : AddCont} -> c =%+> c
75 | lensInputs : {c, d : AddCont} -> c =%+> d -> AddCont
76 | lensInputs lens = MkAddCont c.Shp (d.Pos . lens.fwd)
79 | namespace DependentCharts
90 | record (=&+>) (c, d : AddCont) where
92 | UChart : UC c =&> UC d
95 | (!&+) : {0 c, d : AddCont} ->
96 | ((x : c.Shp) -> (y : d.Shp ** (c.PosSet x -> d.PosSet y))) ->
98 | (!&+) f = (!&) ((!&) f)
101 | (&!+) : {0 c, d : AddCont} -> c =&+> d -> (x : c.Shp) -> (y : d.Shp ** (c.PosSet x -> d.PosSet y))
102 | (&!+) (!& f) = (&!) f
105 | (.fwd) : {0 c, d : AddCont} -> c =&+> d -> c.Shp -> d.Shp
106 | (.fwd) f = (UChart f).fwd
109 | (.bwd) : {0 c, d : AddCont} -> (f : c =&+> d) ->
110 | (x : c.Shp) -> c.PosSet x -> d.PosSet (f.fwd x)
111 | (.bwd) f = (UChart f).bwd
114 | compDepChart : {0 c, d, e : AddCont} -> c =&+> d -> d =&+> e -> c =&+> e
115 | compDepChart f g = (!&) (compDepChart (UChart f) (UChart g))
118 | (&+>>) : {0 c, d, e : AddCont} -> c =&+> d -> d =&+> e -> c =&+> e
119 | (&+>>) = compDepChart
122 | id : {0 c : AddCont} -> c =&+> c
128 | chartInputs : {c, d : AddCont} -> (0 f : c =&+> d) -> AddCont
135 | valuedIn : AddCont -> ComMonoid -> AddCont
136 | valuedIn c y = MkAddCont c.Shp
137 | (\s => (
ComMonoidHomo (c.Pos s) y ** functionIsMonoid (snd y))
)
141 | dual : AddCont -> AddCont
142 | dual c = valuedIn c natMon
146 | dualiseChart : {c, d : AddCont} -> {y : ComMonoid} ->
147 | c =&+> d -> (c `valuedIn` y) =%+> (d `valuedIn` y)
148 | dualiseChart f = !% chartToLens (UChart f)