@@ -10,86 +10,66 @@ Two different types of morphisms:
1010dependent lenses, and dependent charts
1111-------------------------------------------------------------------------------}
1212
13- export infixr 1 =%> -- dependent lens
14- export infixr 1 =&> -- dependent chart
15- export infix 1 <%! -- constructor for dependent lens
16- export infix 1 <&! -- constructor for dependent chart
17- export prefix 0 !% -- constructor for closed dependent lens
18- export prefix 0 !& -- constructor for closed dependent chart
13+ export infixr 1 =%> -- (closed) dependent lens
14+ export infixr 1 =&> -- (closed) dependent chart
15+ export prefix 0 !% -- constructor the (closed) dependent lens
16+ export prefix 0 !& -- constructor the (closed) dependent chart
1917export infixl 5 %>> -- composition of dependent lenses
18+ export infixl 5 &>> -- composition of dependent charts
2019
2120namespace DependentLenses
2221 ||| Dependent lenses
2322 ||| Forward-backward container morphisms
2423 public export
25- record (=%> ) (c1, c2 : Cont) where
26- constructor (<%! )
27- fwd : c1.Shp -> c2.Shp
28- bwd : (x : c1.Shp) -> c2.Pos (fwd x) -> c1.Pos x
24+ data (=%> ) : (c1, c2 : Cont) -> Type where
25+ (!% ) : ((x : c1.Shp) -> (y : c2.Shp ** (c2.Pos y -> c1.Pos x))) -> c1 =%> c2
2926
3027 % name (=%> ) f, g, h
31-
32-
33- ||| Constructor for closed dependent lens
34- public export
35- (!% ) : {0 c1, c2 : Cont} ->
36- ((x : c1.Shp) -> (y : c2.Shp ** (c2.Pos y -> c1.Pos x))) ->
37- c1 =%> c2
38- (!% ) f = (\ x => fst (f x)) <%! (\ x => snd (f x))
3928
4029 public export
41- (%! ) : {0 c1, c2 : Cont} ->
42- (f : c1 =%> c2) ->
43- (x : c1.Shp) -> (y : c2.Shp ** (c2.Pos y -> c1.Pos x))
44- (%! ) f x = (f. fwd x ** f. bwd x)
30+ (%! ) : c1 =%> c2 -> (x : c1.Shp) -> (y : c2.Shp ** (c2.Pos y -> c1.Pos x))
31+ (%! ) (!% f) x = f x
4532
4633 ||| Composition of dependent lenses
4734 public export
4835 compDepLens : a =%> b -> b =%> c -> a =%> c
49- compDepLens f g =
50- (g. fwd . f. fwd) <%!
51- (\ x => f. bwd x . g. bwd (f. fwd x))
52-
36+ compDepLens (!% f) (!% g) = !% \ x => let (b ** kb) = f x
37+ (c ** kc) = g b
38+ in (c ** kb . kc)
5339 public export
5440 (%>> ) : a =%> b -> b =%> c -> a =%> c
5541 (%>> ) = compDepLens
5642
5743 public export
5844 id : a =%> a
59- id = !% \ x => (x ** \ y => y )
45+ id = !% \ x => (x ** id )
6046
6147namespace DependentCharts
6248 ||| Dependent charts
6349 ||| Forward-forward container morphisms
6450 public export
65- record (=&> ) (c1, c2 : Cont) where
66- constructor (<&! )
67- fwd : c1.Shp -> c2.Shp
68- fwd' : (x : c1.Shp) -> c1.Pos x -> c2.Pos (fwd x)
69-
70-
71- ||| Constructor for closed dependent chart
72- public export
73- (!& ) : {0 c1, c2 : Cont} ->
74- ((x : c1.Shp) -> (y : c2.Shp ** (c1.Pos x -> c2.Pos y))) ->
75- c1 =&> c2
76- (!& ) f = (\ x => fst (f x)) <&! (\ x => snd (f x))
51+ data (=&> ) : (c1, c2 : Cont) -> Type where
52+ (!& ) : ((x : c1.Shp) -> (y : c2.Shp ** (c1.Pos x -> c2.Pos y))) -> c1 =&> c2
7753
54+ % name (=&> ) f, g, h
7855
56+ public export
57+ (%! ) : c1 =&> c2 -> (x : c1.Shp) -> (y : c2.Shp ** (c1.Pos x -> c2.Pos y))
58+ (%! ) (!& f) x = f x
59+
7960 public export
8061 compDepChart : a =&> b -> b =&> c -> a =&> c
81- compDepChart f g =
82- (g . fwd . f . fwd) <&!
83- ( \ x => g . fwd' (f . fwd x) . f . fwd' x )
62+ compDepChart ( !& f) ( !& g) = !& \ x => let (b ** kb) = f x
63+ (c ** kc) = g b
64+ in (c ** kc . kb )
8465
8566 public export
8667 (&>> ) : a =&> b -> b =&> c -> a =&> c
8768 (&>> ) = compDepChart
8869
8970 public export
9071 id : a =&> a
91- id = !& \ x => (x ** \ y => y)
92-
72+ id = !& \ x => (x ** id )
9373
9474-- experimental stuff below
9575||| TODO is this the extension of a container?
@@ -101,16 +81,5 @@ val (shp !> pos) r = (s : shp) !> (pos s -> r)
10181valContMap : {c1, c2 : Cont} -> {r : Type }
10282 -> (f : c1 =&> c2)
10383 -> (c1 `val` r) =%> (c2 `val` r)
104- valContMap {c1= (shp !> pos)} {c2= (shp' !> pos')} (fwd <&! fwd')
105- = fwd <%! (\ x, k, x' => k (fwd' x x'))
106-
107- -- ||| A container morphism
108- -- public export
109- -- record (~%>) (c1, c2 : ContF R) where
110- -- constructor (<~!)
111- -- fwd' : c1.Shp' -> c2.Shp'
112-
113-
114- -- upd : c1 ~%> c2 ->
115- -- %pair (=%>) fwd bwd
116-
84+ valContMap {c1= (shp !> pos)} {c2= (shp' !> pos')} (!& f)
85+ = !% \ x => let (y ** ky) = f x in (y ** (. ky))
0 commit comments