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
63 | (%>>) : c =%> d -> d =%> e -> c =%> e
68 | id = !% \x => (
x ** id)
78 | lensInputs : {c, d : Cont} -> c =%> d -> Cont
79 | lensInputs lens = (x : c.Shp) !> d.Pos (lens.fwd x)
82 | namespace DependentCharts
92 | data (=&>) : (c, d : Cont) -> Type where
93 | (!&) : ((x : c.Shp) -> (y : d.Shp ** (c.Pos x -> d.Pos y))) -> c =&> d
98 | (&!) : c =&> d -> (x : c.Shp) -> (y : d.Shp ** (c.Pos x -> d.Pos y))
104 | (.fwd) : c =&> d -> c.Shp -> d.Shp
105 | (.fwd) f = \x => ((&! f) x).fst
108 | (.bwd) : (f : c =&> d) -> (x : c.Shp) -> c.Pos x -> d.Pos (f.fwd x)
109 | (.bwd) f = \x => ((&! f) x).snd
112 | compDepChart : c =&> d -> d =&> e -> c =&> e
113 | compDepChart f g = !& \x => let (
y ** ky)
= (&! f) x
114 | (
z ** kz)
= (&! g) y
118 | (&>>) : c =&> d -> d =&> e -> c =&> e
119 | (&>>) = compDepChart
123 | id = !& \x => (
x ** id)
126 | namespace Cartesian
131 | data (=:>) : (c, d : Cont) -> Type where
132 | (!:) : ((x : c.Shp) -> (y : d.Shp ** Iso (c.Pos x) (d.Pos y)))
135 | %name (=:>)
f, g, h
138 | (:!) : c =:> d -> ((x : c.Shp) -> (y : d.Shp ** Iso (c.Pos x) (d.Pos y)))
139 | (:!) (!: f) x = f x
143 | (:%) : c =:> d -> c =%> d
144 | (:%) (!: f) = !% \x => let (
y ** ky)
= f x in (
y ** backward ky)
148 | (:&) : c =:> d -> c =&> d
149 | (:&) (!: f) = !& \x => let (
y ** ky)
= f x in (
y ** forward ky)
152 | reduceVia : {0 c, d : Cont} ->
153 | ((s' : d.Shp) -> d.Pos s') ->
155 | ((s : c.Shp) -> c.Pos s)
156 | reduceVia f l s = l.bwd s (f (l.fwd s))
163 | valuedIn : Cont -> Type -> Cont
164 | valuedIn c r = (s : c.Shp) !> (c.Pos s -> r)
169 | chartToLens : {c1, c2 : Cont} -> {r : Type}
171 | -> (c1 `valuedIn` r) =%> (c2 `valuedIn` r)
172 | chartToLens f = !% \x => let (
y ** ky)
= (((&!) f) x)