@@ -62,19 +62,32 @@ rebuildEnv (x :: xs) SubNil [] = x :: xs
62---- The Effect EDSL itself ----
62---- The Effect EDSL itself ----
64-- some proof automation
64-- some proof automation
65−findEffElem : Nat -> List (TTName, Binder TT) -> TT -> Tactic -- Nat is maximum search depth
65+
67+reflectListEffElem : List a -> Tactic
66−findEffElem Z ctxt goal = Refine "Here" `Seq` Solve
68+reflectListEffElem [] = Refine "Here" `Seq` Solve
67−findEffElem (S n) ctxt goal = GoalType "EffElem"
69+reflectListEffElem (x :: xs)
68− (Try (Refine "Here" `Seq` Solve)
70+ = Try (Refine "Here" `Seq` Solve)
69− (Refine "There" `Seq` (Solve `Seq` findEffElem n ctxt goal)))
71+ (Refine "There" `Seq` (Solve `Seq` reflectListEffElem xs))
70−
72+reflectListEffElem (x ++ y) = Refine "Here" `Seq` Solve
71−findSubList : Nat -> List (TTName, Binder TT) -> TT -> Tactic
73+reflectListEffElem _ = Refine "Here" `Seq` Solve
76+reflectSubList : List a -> Tactic
72−findSubList Z ctxt goal = Refine "SubNil" `Seq` Solve
77+reflectSubList [] = Refine "SubNil" `Seq` Solve
73−findSubList (S n) ctxt goal
78+reflectSubList (x :: xs)
75− (Try (Refine "subListId" `Seq` Solve)
79+ = Try (Refine "subListId" `Seq` Solve)
76− ((Try (Refine "Keep" `Seq` Solve)
80+ (Try (Refine "Keep" `Seq` (Solve `Seq` reflectSubList xs))
77− (Refine "Drop" `Seq` Solve)) `Seq` findSubList n ctxt goal))
81+ (Refine "Drop" `Seq` (Solve `Seq` reflectSubList xs)))
82+reflectSubList (x ++ y) = Refine "subListId" `Seq` Solve
83+reflectSubList _ = Refine "subListId" `Seq` Solve
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
79updateResTy : (xs : List EFFECT) -> EffElem e a xs -> e a b t ->
92updateResTy : (xs : List EFFECT) -> EffElem e a xs -> e a b t ->
80 List EFFECT
93 List EFFECT
@@ -135,46 +148,47 @@ syntax [tag] ":!" [val] = !(tag :- val)
135-- Eff : List (EFFECT m) -> Type -> Type
148-- Eff : List (EFFECT m) -> Type -> Type
138−lift' : {default tactics { applyTactic findSubList 20; solve; }
151+lift' : EffM m ys ys' t ->
152+ {default tactics { byReflection reflectEff; }
139 prf : SubList ys xs} ->
153 prf : SubList ys xs} ->
140− EffM m ys ys' t -> EffM m xs (updateWith ys' xs prf) t
154+ EffM m xs (updateWith ys' xs prf) t
141−lift' {prf} e = lift prf e
155+lift' e {prf} = lift prf e
144effect' : {a, b: _} -> {e : Effect} ->
158effect' : {a, b: _} -> {e : Effect} ->
145− {default tactics { applyTactic findEffElem 20; solve; }
146− prf : EffElem e a xs} ->
147 (eff : e a b t) ->
159 (eff : e a b t) ->
160+ {default tactics { byReflection reflectEff; }
161+ prf : EffElem e a xs} ->
148 EffM m xs (updateResTy xs prf eff) t
162 EffM m xs (updateResTy xs prf eff) t
149−effect' {prf} e = effect prf e
163+effect' e {prf} = effect prf e
151-- For making proofs implicitly for 'test' and 'test_lbl'
165-- For making proofs implicitly for 'test' and 'test_lbl'
153syntax if_valid then [e] else [t] =
167syntax if_valid then [e] else [t] =
154− test (tactics { applyTactic findEffElem 20; solve; }) t e
168+ test (tactics { byReflection reflectEff; }) t e
156syntax if_valid [lbl] then [e] else [t] =
170syntax 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
159syntax if_error then [t] else [e] =
173syntax if_error then [t] else [e] =
160− test (tactics { applyTactic findEffElem 20; solve; }) t e
174+ test (tactics { byReflection reflectEff; }) t e
162syntax if_error [lbl] then [t] else [e] =
176syntax 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
165-- These may read better in some contexts
179-- These may read better in some contexts
167syntax if_right then [e] else [t] =
181syntax if_right then [e] else [t] =
168− test (tactics { applyTactic findEffElem 20; solve; }) t e
182+ test (tactics { byReflection reflectEff; }) t e
170syntax if_right [lbl] then [e] else [t] =
184syntax 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
173syntax if_left then [t] else [e] =
187syntax if_left then [t] else [e] =
174− test (tactics { applyTactic findEffElem 20; solve; }) t e
188+ test (tactics { byReflection reflectEff; }) t e
176syntax if_left [lbl] then [t] else [e] =
190syntax 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
180-- for 'do' notation
194-- for 'do' notation