| Frac (t1, t2) -> Frac (k t1, k t2)
| Sqrt t -> Sqrt (k t)
| Root (arg, index) -> Root (k arg, k index)
-(* | Break -> Break *)
+ | Break -> Break
| Box (kind, terms) -> Box (kind, List.map k terms)
let visit_magic k = function
| Opt t -> Opt (k t)
| Fold (kind, t1, names, t2) -> Fold (kind, k t1, names, k t2)
| Default (t1, t2) -> Default (k t1, k t2)
- | If (t1, t2) -> If (k t1, k t2)
- | Unless (t1, t2) -> Unless (k t1, k t2)
+ | If (t1, t2, t3) -> If (k t1, k t2, k t3)
+ | Fail -> Fail
let variables_of_term t =
let rec vars = ref [] in
| Fold (_, t1, _, t2) ->
aux t1 ;
aux t2
+ | If (t1, t2, t3) ->
+ aux t1 ;
+ aux t2 ;
+ aux t3
+ | Fail -> ()
| _ -> assert false
in
aux term ;
in
aux [] ap
+let rec find_branch =
+ function
+ Magic (If (_, Magic Fail, t)) -> find_branch t
+ | Magic (If (_, t, _)) -> find_branch t
+ | t -> t