Skip to content

Commit

Permalink
Add dest_path to Conv
Browse files Browse the repository at this point in the history
  • Loading branch information
Magnus Myreen authored and mn200 committed Jun 12, 2024
1 parent 8d8eefd commit b67a714
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/1/Conv.sig
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,7 @@ sig

val memoize : (term -> 'a option) -> ('a, thm) Redblackmap.dict ->
(term -> bool) -> exn -> conv -> conv

val dest_path : string -> term -> term

end
17 changes: 17 additions & 0 deletions src/1/Conv.sml
Original file line number Diff line number Diff line change
Expand Up @@ -2552,6 +2552,23 @@ in
fn pat => PCONV (strip_abs pat)
end

fun dest_path path =
let
fun compose f g x = f (g x)
fun abs_body tm = #Body (dest_abs tm)
fun binder_body tm =
if is_abs tm then abs_body tm else abs_body (rand tm)
fun loop [] = I
| loop (c::cs) =
if c = #"a" then compose (loop cs) abs_body else
if c = #"b" then compose (loop cs) binder_body else
if c = #"l" then compose (loop cs) rator else
if c = #"r" then compose (loop cs) rand else
failwith ("dest_path does not understand: " ^ str c)
in
loop (explode path)
end;

fun PATH_CONV path c =
let
val limit = size path
Expand Down

0 comments on commit b67a714

Please sign in to comment.