Closed conal closed 8 years ago
Sorry, not ignoring this, just haven't had time to play around with it yet.
I think if you had the recursive-let expression, you could write a rewrite to pick out one binding into an enclosing non-recursive let (failing if any of the recursive bindings are in the RHS of the new non-recursive binding... and if it fails, inlining that binding to undo the abstraction). Then just iterate that to get a big pile of nested non-recursive let expressions, which would be straightforward to convert to lambdas.
Thanks. Given your suggestion and my current specialized solution, I'm closing the ticket.
I'd like to abstract out all sub-expressions meeting some given criterion, resulting in a multi-beta-redex, i.e.,
where the
ri
are the subterms of the LHS that satisfy the criterion, and thevi
are fresh variables, and theri
don't contain variables that go out of scope.I haven't found a simple & efficient construction out of given combinators. I'd rather not painstakingly verify that the
vi
don't occur freely in theri
.It's easier for me to see how to define a
let
counterpart:but then I've lost the non-occurrence property, so I don't know how to convert to a multi-beta-redex,
without having to verify that the
vi
don't occur freely in theri
.After tinkering with this one for a while, I thought I'd ask whether this puzzle is already solved well.