0 | module Data.Container.Base.Morphism.Definition
4 | import Data.Container.Base.Object.Definition
22 | public export prefix 0 %!
23 | public export prefix 0 &!
24 | public export prefix 0 :!
28 | namespace DependentLenses
38 | data (=%>) : (c, d : Cont) -> Type where
39 | (!%) : ((x : c.Shp) -> (y : d.Shp ** (d.Pos y -> c.Pos x))) -> c =%> d
44 | (%!) : c =%> d -> (x : c.Shp) -> (y : d.Shp ** (d.Pos y -> c.Pos x))
49 | (.fwd) : c =%> d -> c.Shp -> d.Shp
50 | (.fwd) (!% f) x = (f x).fst
53 | (.bwd) : (f : c =%> d) -> (x : c.Shp) -> d.Pos (f.fwd x) -> c.Pos x
54 | (.bwd) (!% f) x y' = (f x).snd y'
58 | compDepLens : c =%> d -> d =%> e -> c =%> e
59 | compDepLens f g = !% \x => let (
y ** ky)
= (%!) f x
60 | (
z ** kz)
= (%!) g y
64 | (%>>) : c =%> d -> d =%> e -> c =%> e
69 | id = !% \x => (
x ** id)
79 | lensInputs : {c, d : Cont} -> c =%> d -> Cont
80 | lensInputs lens = (x : c.Shp) !> d.Pos (lens.fwd x)
83 | namespace DependentCharts
93 | data (=&>) : (c, d : Cont) -> Type where
94 | (!&) : ((x : c.Shp) -> (y : d.Shp ** (c.Pos x -> d.Pos y))) -> c =&> d
99 | (&!) : c =&> d -> (x : c.Shp) -> (y : d.Shp ** (c.Pos x -> d.Pos y))
100 | (&!) (!& f) x = f x
105 | (.fwd) : c =&> d -> c.Shp -> d.Shp
106 | (.fwd) f = \x => ((&! f) x).fst
109 | (.bwd) : (f : c =&> d) -> (x : c.Shp) -> c.Pos x -> d.Pos (f.fwd x)
110 | (.bwd) f = \x => ((&! f) x).snd
113 | compDepChart : c =&> d -> d =&> e -> c =&> e
114 | compDepChart f g = !& \x => let (
y ** ky)
= (&!) f x
115 | (
z ** kz)
= (&!) g y
119 | (&>>) : c =&> d -> d =&> e -> c =&> e
120 | (&>>) = compDepChart
124 | id = !& \x => (
x ** id)
127 | namespace Cartesian
132 | data (=:>) : (c, d : Cont) -> Type where
133 | (!:) : ((x : c.Shp) -> (y : d.Shp ** Iso (c.Pos x) (d.Pos y)))
136 | %name (=:>)
f, g, h
139 | (:!) : c =:> d -> ((x : c.Shp) -> (y : d.Shp ** Iso (c.Pos x) (d.Pos y)))
140 | (:!) (!: f) x = f x
144 | (:%) : c =:> d -> c =%> d
145 | (:%) (!: f) = !% \x => let (
y ** ky)
= f x in (
y ** backward ky)
149 | (:&) : c =:> d -> c =&> d
150 | (:&) (!: f) = !& \x => let (
y ** ky)
= f x in (
y ** forward ky)
153 | reduceVia : {0 c, d : Cont} ->
154 | ((s' : d.Shp) -> d.Pos s') ->
156 | ((s : c.Shp) -> c.Pos s)
157 | reduceVia f l s = l.bwd s (f (l.fwd s))
165 | valuedIn : Cont -> Type -> Cont
166 | valuedIn c r = (s : c.Shp) !> (c.Pos s -> r)
171 | chartToLens : {c1, c2 : Cont} -> {r : Type}
173 | -> (c1 `valuedIn` r) =%> (c2 `valuedIn` r)
174 | chartToLens f = !% \x => let (
y ** ky)
= (&!) f x