@@ -62,19 +62,32 @@ rebuildEnv (x :: xs) SubNil [] = x :: xs
6262---- The Effect EDSL itself ----
6363
6464-- some proof automation
65−findEffElem : Nat -> List (TTName, Binder TT) -> TT -> Tactic -- Nat is maximum search depth
66−findEffElem Z ctxt goal = Refine "Here" `Seq` Solve
67−findEffElem (S n) ctxt goal = GoalType "EffElem"
68− (Try (Refine "Here" `Seq` Solve)
69− (Refine "There" `Seq` (Solve `Seq` findEffElem n ctxt goal)))
70−
71−findSubList : Nat -> List (TTName, Binder TT) -> TT -> Tactic
72−findSubList Z ctxt goal = Refine "SubNil" `Seq` Solve
73−findSubList (S n) ctxt goal
74− = GoalType "SubList"
75− (Try (Refine "subListId" `Seq` Solve)
76− ((Try (Refine "Keep" `Seq` Solve)
77− (Refine "Drop" `Seq` Solve)) `Seq` findSubList n ctxt goal))
65+
66+%reflection
67+reflectListEffElem : List a -> Tactic
68+reflectListEffElem [] = Refine "Here" `Seq` Solve
69+reflectListEffElem (x :: xs)
70+ = Try (Refine "Here" `Seq` Solve)
71+ (Refine "There" `Seq` (Solve `Seq` reflectListEffElem xs))
72+reflectListEffElem (x ++ y) = Refine "Here" `Seq` Solve
73+reflectListEffElem _ = Refine "Here" `Seq` Solve
74+
75+%reflection
76+reflectSubList : List a -> Tactic
77+reflectSubList [] = Refine "SubNil" `Seq` Solve
78+reflectSubList (x :: xs)
79+ = Try (Refine "subListId" `Seq` Solve)
80+ (Try (Refine "Keep" `Seq` (Solve `Seq` reflectSubList xs))
81+ (Refine "Drop" `Seq` (Solve `Seq` reflectSubList xs)))
82+reflectSubList (x ++ y) = Refine "subListId" `Seq` Solve
83+reflectSubList _ = Refine "subListId" `Seq` Solve
84+
85+%reflection
86+reflectEff : (P : Type) -> Tactic
87+reflectEff (EffElem m a xs)
88+ = reflectListEffElem xs `Seq` Solve
89+reflectEff (SubList xs ys)
90+ = reflectSubList ys `Seq` Solve
7891
7992updateResTy : (xs : List EFFECT) -> EffElem e a xs -> e a b t ->
8093 List EFFECT
@@ -135,46 +148,47 @@ syntax [tag] ":!" [val] = !(tag :- val)
135148-- Eff : List (EFFECT m) -> Type -> Type
136149
137150implicit
138−lift' : {default tactics { applyTactic findSubList 20; solve; }
151+lift' : EffM m ys ys' t ->
152+ {default tactics { byReflection reflectEff; }
139153 prf : SubList ys xs} ->
140− EffM m ys ys' t -> EffM m xs (updateWith ys' xs prf) t
141−lift' {prf} e = lift prf e
154+ EffM m xs (updateWith ys' xs prf) t
155+lift' e {prf} = lift prf e
142156
143157implicit
144158effect' : {a, b: _} -> {e : Effect} ->
145− {default tactics { applyTactic findEffElem 20; solve; }
146− prf : EffElem e a xs} ->
147159 (eff : e a b t) ->
160+ {default tactics { byReflection reflectEff; }
161+ prf : EffElem e a xs} ->
148162 EffM m xs (updateResTy xs prf eff) t
149−effect' {prf} e = effect prf e
163+effect' e {prf} = effect prf e
150164
151165-- For making proofs implicitly for 'test' and 'test_lbl'
152166
153167syntax if_valid then [e] else [t] =
154− test (tactics { applyTactic findEffElem 20; solve; }) t e
168+ test (tactics { byReflection reflectEff; }) t e
155169
156170syntax if_valid [lbl] then [e] else [t] =
157− test_lbl {x=lbl} (tactics { applyTactic findEffElem 20; solve; }) t e
171+ test_lbl {x=lbl} (tactics { byReflection reflectEff; }) t e
158172
159173syntax if_error then [t] else [e] =
160− test (tactics { applyTactic findEffElem 20; solve; }) t e
174+ test (tactics { byReflection reflectEff; }) t e
161175
162176syntax if_error [lbl] then [t] else [e] =
163− test_lbl {x=lbl} (tactics { applyTactic findEffElem 20; solve; }) t e
177+ test_lbl {x=lbl} (tactics { byReflection reflectEff; }) t e
164178
165179-- These may read better in some contexts
166180
167181syntax if_right then [e] else [t] =
168− test (tactics { applyTactic findEffElem 20; solve; }) t e
182+ test (tactics { byReflection reflectEff; }) t e
169183
170184syntax if_right [lbl] then [e] else [t] =
171− test_lbl {x=lbl} (tactics { applyTactic findEffElem 20; solve; }) t e
185+ test_lbl {x=lbl} (tactics { byReflection reflectEff; }) t e
172186
173187syntax if_left then [t] else [e] =
174− test (tactics { applyTactic findEffElem 20; solve; }) t e
188+ test (tactics { byReflection reflectEff; }) t e
175189
176190syntax if_left [lbl] then [t] else [e] =
177− test_lbl {x=lbl} (tactics { applyTactic findEffElem 20; solve; }) t e
191+ test_lbl {x=lbl} (tactics { byReflection reflectEff; }) t e
178192
179193
180194-- for 'do' notation