-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproto.dats
1555 lines (1416 loc) · 33 KB
/
proto.dats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(*
** Prototype.
**
** Translated directly from the paper.
** Some testing code thrown in.
**
** You can paste it into Try ATS.
*)
(* ****** ****** *)
//
#define
LIBATSCC2JS_targetloc
"$PATSHOME/contrib/libatscc2js/ATS2-0.3.2"
//
#include
"{$LIBATSCC2JS}/staloadall.hats"
//
(* ****** ****** *)
staload
"{$LIBATSCC2JS}/SATS/print.sats"
staload
"{$LIBATSCC2JS}/SATS/ML/list0.sats"
staload
"{$LIBATSCC2JS}/SATS/filebas.sats"
staload
"{$LIBATSCC2JS}/SATS/list.sats"
staload
"{$LIBATSCC2JS}/SATS/JSarray.sats"
(* ****** ****** *)
#define ATS_MAINATSFLAG 1
#define ATS_DYNLOADNAME "my_dynload"
(* ****** ****** *)
extern
fun
escape_html (string): string = "mac#"
extern
fun
JSarray_clear {a:t@ype} (JSarray(a)): void = "mac#"
abstype html_env = ptr
extern
fun
html_env_init () : html_env = "mac#"
extern
fun
html_tag_open (html_env, tagname : string, attributes: List '(string,string)): void = "mac#"
extern
fun
html_text (html_env, string): void = "mac#"
extern
fun
html_tag (html_env, tagname: string): void = "mac#"
extern
fun
html_tag_close (html_env): void = "mac#"
extern
fun
html_env_html (html_env): string = "mac#"
assume html_env = '(JSarray string, JSarray string)
implement
html_env_init () = '(JSarray_nil(), JSarray_nil ())
implement
html_tag_open (h, tagname, attribs) = let
val x = "<" + tagname + (if list_is_nil attribs then "" else " ")
val _ = JSarray_push (h.1, tagname)
fun
aux (ls: List '(string, string)): void =
case+ ls of
| list_nil () => let
val _ = JSarray_push (h.0, ">")
in
end
| list_cons ('(attr, value), ls) => let
val _ = JSarray_push (h.0, escape_html attr + "=\"" + escape_html value + "\"")
in
aux (ls)
end
val _ = JSarray_push (h.0, x)
val () = aux (attribs)
in
end
implement
html_text (h, text) = let
val text = escape_html text
val _ = JSarray_push (h.0, text)
in
end
implement
html_tag_close (h) =
let
val n = JSarray_length (h.1)
in
case+ n of
| 0 => alert "woohoo"
| _ => let
val tn = JSarray_pop (h.1)
val _ = JSarray_push (h.0, "</" + tn + ">")
in
end
end
implement
html_env_html (h) = JSarray_join (h.0)
val the_html_env = html_env_init ()
extern
fun
html_env_reset (): void = "mac#"
implement
html_env_reset () = {
val () = JSarray_clear (the_html_env.0)
val () = JSarray_clear (the_html_env.1)
}
local
macrodef
rec
auxlist
(xs, y) =
(
//
if iscons! (xs) then
`(,(car! xs); ,(auxlist (cdr! xs, y)))
else y // end of [if]
//
) // end of [auxlist]
in (* in of [local] *)
macrodef
TAG (tag, a, r) = `({
val () = html_tag_open (the_html_env, ,(tag), ,(a))
val () = ,(if islist! (r) then auxlist (r, `())
else `(,(r)))
val () = html_tag_close (the_html_env)
})
macdef
P (a, r) = ,(TAG (`("p"), a, r))
macdef
STRONG (a, r) = ,(TAG (`("strong"), a, (r)))
macdef
DIV (a, r) = ,(TAG (`("div"), a, r))
macdef
TEXT (ls) = {
val () = html_text (the_html_env, ,(ls))
}
end // end of [local]
extern
fun
test_html(): void = "mac#"
implement
test_html() = let
val _ = P (list_cons('("class", "selected"), list_nil), TEXT ("hi"), STRONG (list_nil, TEXT ("there")), TEXT ("!"))
(*
val () = html_tag_open ("p", list_nil)
val () = html_text (env, "hello ")
val () = html_tag_open (env, "strong", list_nil)
val () = html_text (env, "person")
val () = html_tag_close (env)
val () = html_text (env, "!")
val () = html_tag_close (env)
*)
val () = alert (html_env_html (the_html_env))
in
end
(*
// simple HTML output, how?
// print it!
// or, minimal DOM entry
absvtype dom (bool(*text node*), l:addr) = ptr
vtypedef dom0 (b:bool) = [l:addr] dom (b, l)
vtypedef dom1 (b:bool) = [l:agz] dom (b, l)
vtypedef domelt0 = [l:addr] dom (false, l)
vtypedef domtext0 = [l:addr] dom (true, l)
vtypedef domelt1 = [l:agz] dom (false, l)
vtypedef domtext = [l:agz] dom (true, l)
absvtype domseq (l:addr) = ptr
vtypedef domseq0 = [l:addr] domseq (l)
extern
fun
appendChild (parent : !domelt1, newChild : dom1): void
(* moves the tree newChild
to the end of parent’s child list. Requires that parent
exists and is not a text node, and that newChild exists
and is not an ancestor of parent, or it faults.
*)
extern
fun
removeChild (parent : !domelt1, oldChildIndex : int) : dom0
(* removes the tree oldChild
from the tree parent’s child forest and re-inserts it at
the root of the grove. Requires that parent exists and
oldChild is a child of parent, or it faults.
*)
extern
fun
getNodeName (node : !domelt1) : string
(* assigns to the variable name
the nodeName value of node if it exists, or it faults. If
node is a text node, then name = #text.
*)
extern
fun
getParentNode (node : !domelt1) : Option string
(* assigns to the variable id the
identifier of the parent of node, if it exists, and null
otherwise. Requires that node exists or it faults.
*)
extern
fun
getChildNodes {l:agz} (node : dom (false, l)) : [l1:addr] (domseq (l1) -<lin,prf> dom (false, l) | domseq0 (l1))
(*
fid := getChildNodes (node : dom) : doms assigns to the variable fid
the identifier of the child forest of the element node,
which must exist or it faults.
*)
extern
fun
createNode (Name : string) : domelt1
(*creates a new element node at
the root of the grove, with fresh id and fid and a
name equal to Name, and records its identifier in the
variable node. It faults if JNameKs 6∈ EltNames.
*)
extern
fun
item {l:agz} (list : domseq0 (l), i: int) : dom // takeout?
(* sets the variable node to the Int+
1th node in the list pointed to by list, setting it to
null if Int evaluates to an invalid index. It faults if
list does not exist.
*)
extern
fun
substringData (node : !domtext1, Offset : int, Count : int) : string
(* assigns to the
variable str the substring of the string of the text node
node starting at character Offset with length Count.
If Offset + Count exceeds the string length, then all
the characters to the string end are returned. Requires
that node exists, Offset and Count be non-negative,
and Offset be at most the string length, or it faults.
*)
extern
fun
appendData (node : !domtext1, Arg : string) : void
(* appends the string Arg to the end
of the string contained in node. Requires that node
exists and be a text node, or it faults.
*)
extern
fun
deleteData (node : !domtext1, Offset : int, Count : int) : void
(* deletes the substring of
the string of node starting at the character Offset
with length Count. If Offset + Count exceeds the
string length, then all the characters to the string end
are deleted. Requires that node exists, Offset and
Count be non-negative, and Offset be at most the
string length, or it faults.
*)
extern
fun
createTextNode (Str : text) : domtext1
(* creates a new text node at
the grove level, with fresh id and the string contained
within the text node set to Str, and records the new
node’s identifier in the variable node.
*)
*)
(* ****** ****** *)
abstype label = ptr
extern
fun
assl (label): bool = "mac#" // associates to the left
extern
fun
prec (label) : int = "mac#" // precedence
extern
fun
is_hole (label): bool = "mac#"
extern
fun
print_label : (label) -> void = "mac#"
overload print with print_label of 100
extern
fun
eq_label_label : (label, label) -> bool = "mac#"
overload = with eq_label_label
extern
fun
class_label : (label) -> string = "mac#"
abstype tree = ptr
extern
fun
tree_atom (label): tree = "mac#"
extern
fun
tree_fork (label, List tree): tree = "mac#"
extern
fun
tree_is_fork (tree): bool = "mac#"
//
extern
fun
print_tree (tree): void = "mac#"
overload print with print_tree of 100
extern
fun
eq_tree_tree (tree, tree): bool = "mac#"
overload = with eq_tree_tree
extern
fun
template (label) : tree = "mac#"
extern
val
hole : tree
extern
fun
label : tree -> label = "mac#"
extern
fun
children : tree -> List tree = "mac#"
extern
fun
atomic : tree -> bool = "mac#"
(* ****** ****** *)
extern
fun
myprint (tree): void = "mac#"
implement
print_val<tree> (t) = myprint (t)
implement
myprint (t) = {
val label = label t
val cs = children t
val () = print("fork(")
val () = print(label)
val () = print(",")
implement
print_val<tree> (t) = myprint (t)
val () = print("[")
val () = print(cs)
val () = print("]")
val () = print(")")
}
implement
print_tree (t) = myprint (t)
local
datatype tree0 =
| fork of (label, JSarray tree0)
// deriving (Eq, Ord, Show)
assume tree = tree0
in
implement
label (fork (l, _)) = l
implement
children (fork (_, ts)) = let
val n = JSarray_length ts
fun
aux (i : int, res : List tree) : List tree =
if i >= 0 then let
val t = JSarray_get_at(ts, i)
prval () = lemma_list_param res
val res = list_cons (t, res)
in
aux (i-1, res)
end else res
val res = aux (n-1, list_nil)
in
res
end
implement
atomic (fork (_, cs)) = (JSarray_length cs = 0)
implement
tree_atom (l) = fork (l, JSarray_nil())
implement
tree_fork (l, cs) = fork (l, JSarray_make_list cs)
implement
tree_is_fork (t) = ~atomic t
implement
eq_tree_tree (t1, t2) = let
fun
aux (i: int, n: int, t1: JSarray (tree), t2: JSarray (tree)): bool =
if i < n then let
val a = JSarray_get_at (t1, i)
val b = JSarray_get_at (t2, i)
in
if eq_tree_tree (a, b) then aux (i+1, n, t1, t2)
else false
end else true
// end of [aux]
in
case+ (t1, t2) of
| (fork (l1, c1), fork (l2, c2)) when (l1 = l2) => let
val n1 = JSarray_length c1
val n2 = JSarray_length c2
in
if n1 = n2 then aux (0, n1, c1, c2)
else false
end
| (_, _) => false
end
end // end of [local]
typedef layer = '(label(*label of focussed subtree*), List tree(*children to the left*), List tree(*children to the right*))
typedef path = List layer
typedef subtree = '(path, tree)
extern
fun
embed : (tree, layer) -> tree = "mac#"
extern
fun
selected : subtree -> tree = "mac#"
extern
fun
path : subtree -> path = "mac#"
extern
fun
host : subtree -> tree = "mac#"
extern
fun
root : tree -> subtree = "mac#"
implement
embed (t, '(l,left,right)) =
let
val left = list_reverse left
prval () = lemma_list_param right
val res = list_append (left, list_cons (t, right))
in
tree_fork (l, res)
end
implement
selected '(_, t) = t
implement
path '(p, _) = p
implement
host '(p,t) = list_foldleft (p, t, lam (x,y) =<cloref1> embed (x, y))
implement
root (t) = let
in
'(list_nil(), t)
end
(*
host (root t) = t
selected(root t) = t
*)
(* ****** ****** *)
(* navigation *)
extern
val
left : subtree -> subtree = "mac#"
extern
val
leftmost : subtree -> bool = "mac#"
extern
val
first_child : subtree -> subtree = "mac#" // moves to the left until leftmost
extern
val
right : subtree -> subtree = "mac#"
extern
val
last_child : subtree -> subtree = "mac#" // moves to the right until rightmost
extern
val
rightmost : subtree -> bool = "mac#"
extern
val
up : subtree -> subtree = "mac#"
extern
val
topmost : subtree -> bool = "mac#"
extern
val
back_to_top : subtree -> subtree = "mac#"
extern
val
down : subtree -> subtree = "mac#"
extern
val
bottommost : subtree -> bool = "mac#"
extern
val
at_hole : subtree -> bool = "mac#"
extern
val
next : subtree -> subtree = "mac#"
extern
val
rightup : subtree -> subtree = "mac#"
extern
val
preorder : tree -> List(tree) = "mac#"
extern
val
take_one_while : (subtree -> bool, List subtree) -> List subtree = "mac#"
extern
val
next_such_that : (subtree -> bool, subtree) -> subtree = "mac#"
implement
left st =
let
val '(p, sel) = st
in
case- p of
| list_cons('(lab, list_cons(last,l), r),ls) => let
prval () = lemma_list_param r
in
'(list_cons('(lab, l, list_cons(sel,r)),ls), last)
end
| list_cons('(_, list_nil(), _),_) => st
| list_nil () => st
end
implement
leftmost st =
let
val '(p, sel) = st
in
case+ p of
| list_cons ('(_, list_nil(), _), _) => true
| list_nil () => true
| _ => false
end
implement
first_child st =
if leftmost st then st
else let
val st = left st
in
first_child st
end
implement
right st =
let
val '(p, sel) = st
in
case- p of
| list_cons ( '(lab, l, list_cons(first,r)), ls) => let
prval () = lemma_list_param l
in
'(list_cons ('(lab, list_cons (sel,l), r), ls), first)
end
| list_cons ( '(_, _, list_nil()), _) => st
| list_nil () => st
end
implement
last_child st =
if rightmost st then st
else let
val st = right st
in
last_child st
end
implement
rightmost st =
let
val '(p, sel) = st
in
case+ p of
| list_cons ('(_, _, list_nil()), _) => true
| list_nil () => true
| _ => false
end
(*
left (right st) = st, if not (rightmost st)
right (left st) = st, if not (leftmost st)
*)
implement
up st =
let
val+ '(p, sel) = st
in
case+ p of
| list_cons (layer, above) => '(above, embed (sel, layer))
| list_nil () => st
end
implement
topmost st =
let
val+ '(p, sel) = st
in
list_is_nil p
end
implement
down st =
let
val+ '(p, tr) = st
val lab = label tr
val c = children tr
in
case+ c of
| list_cons (t, ts) => let
prval () = lemma_list_param p
in
'(list_cons ('(lab, list_nil(), ts), p), t)
end
| list_nil () => st
end
implement
bottommost st =
let
val+ '(p, tr) = st
in
atomic tr
end
(*
down (up st) = st, if not (topmost st) && leftmost st
up (down st) = st, if not (bottommost st)
*)
implement
back_to_top st =
if topmost st then st
else let
val st = up st
in
back_to_top st
end
implement
at_hole st =
let
val+ '(ls, tr) = st
val lab = label tr
val c = children tr
in
is_hole lab && list_is_nil c
end
implement
next st =
if bottommost st then
rightup st
else
down st
implement
rightup st =
if topmost st || ~rightmost st then right st
else let
val st = up st
in
rightup st
end
(*
implement
preorder = map selected . takeOneWhile (not . topmost) . iterate next . root
implement
take_one_while (p, xs) = takeWhile p xs
*)
implement
next_such_that (p, st) =
let
fun
aux (st : subtree): subtree =
if topmost st || p st then st
else let
val st = next st
in
aux st
end
val st0 = next st
val st' = aux st0
in
if p st' then st' else st
end
(*
The search stops if a topmost node is reached, but note that
nextSuchThat p st = st
only if st has no proper next successor that satisfies p.
*)
(* ****** ****** *)
(* modification *)
extern
val
replace : (tree, subtree) -> subtree = "mac#"
extern
val
insert : (label, subtree) -> subtree = "mac#"
extern
val
treeinsert : (tree, subtree) -> subtree = "mac#"
extern
val
kill : subtree -> subtree = "mac#"
extern
val
promote : subtree -> subtree = "mac#"
extern
val
situation : subtree -> path = "mac#"
extern
val
graft : (path, subtree) -> subtree = "mac#"
implement
replace (s, '(p, t)) = '(p, s)
(*
replace (selected st) (replace s st) = st
*)
implement
insert (lab, st) =
let
val r = template lab
val st' = treeinsert (r, st)
in
st'
end
implement
treeinsert (t, st) =
if at_hole st then
replace (t, st)
else let
val sel = selected st
val st = replace (t, st)
val st = down st
val st = replace (sel, st)
in
st
end
(*
selection(treeinsert t st) = selection st, if not (atHole st)
*)
implement
kill st = replace (hole, st)
implement
promote st =
let
val sel = selected st
val st = up st
in
replace (sel, st)
end
(*
kill (treeinsert t st) = st, if atHole st
promote (treeinsert t st) = st, if not (atHole st) && not(atomic t)
id (treeinsert t st) = st, if not (atHole st) && atomic t
replace (selected st) (kill st) = st
*)
implement
situation st =
let
val+ '(p, sel) = st
in
case+ p of
| list_cons (c, cs) => list_sing(c)
| list_nil () => p
end
implement
graft (cs, st) =
let
val+ '(p, sel) = st
in
'(list_append (cs, p), sel)
end
(*
graft (situation st) (promote st) = st
*)
(* ****** ****** *)
(* entry *)
extern
val
enter : (label, subtree) -> subtree = "mac#"
extern
val
entry : (label, subtree) -> subtree = "mac#"
extern
val
reduce : (label, subtree) -> subtree = "mac#"
extern
val
irreducible : (label, subtree) -> bool = "mac#"
extern
val
producable : (label, label) -> bool = "mac#"
implement
enter (l, st) =
let
val st = insert (l, st)
in
next_such_that (at_hole, st)
end
implement
entry (l, st) =
let
val st = reduce (l, st)
in
enter (l, st)
end
implement
reduce (l, st) =
if irreducible (l, st) then st
else let
val st = up st
in
reduce (l, st)
end
implement
irreducible (l, st) =
at_hole st || topmost st || ~rightmost st ||
~producable (l, label (selected (up st)))
implement
producable (op2, op1) = (op1 = op2 && assl op1) || prec op1 > prec op2
(* ****** ****** *)
typedef subtree' = '(List (path), tree)
extern
val
unflatten : subtree -> subtree' = "mac#"
extern
val
flatten : subtree' -> subtree = "mac#"
extern
fun{}
lift$fopr : subtree -> subtree
extern
fun{}
lift : subtree' -> subtree'
implement
unflatten '(ps, t) = '(list_sing(ps), t)
implement
flatten '(ps,t) = '(list_concat ps, t)
implement{}
lift st =
let
val '(ps, t) = st
val- list_cons (p, ps') = ps
val '(q, s) = lift$fopr<> '(p, t)
in
'(list_cons (q, ps'), s)
end
extern
val
enter' : (label, subtree') -> subtree'
extern
val
entry' : (label, subtree') -> subtree'
extern
val
left' : subtree' -> subtree'
extern
val
first_child' : subtree' -> subtree'
extern
val
right' : subtree' -> subtree'
extern
val
last_child' : subtree' -> subtree'
extern
val
up' : subtree' -> subtree'
extern
val
down' : subtree' -> subtree'
extern
val
back_to_top' : subtree' -> subtree'
extern
val
insert' : (label, subtree') -> subtree'
extern
val
replace' : (tree, subtree') -> subtree'
extern
val
open : subtree' -> subtree'
extern
val
close : subtree' -> subtree'
implement
entry' (l, st) = lift<> (st) where {
implement
lift$fopr<> st = entry (l, st)
}
implement
left' st = let
implement
lift$fopr<> st = left st
in
lift<> st
end
implement
first_child' st = let
implement
lift$fopr<> st = first_child st
in
lift<> st
end
implement
right' st = let
implement
lift$fopr<> st = right st
in
lift<> st
end
implement
last_child' st = let
implement
lift$fopr<> st = last_child st
in
lift<> st
end
implement
up' st = let
implement
lift$fopr<> st = up st
in
lift<> st
end
implement
down' st = let
implement
lift$fopr<> st = down st
in
lift<> st