conal / lambda-ccc

Convert lambda expressions to CCC combinators
Other
146 stars 18 forks source link

Handle methods without code explosion #9

Open conal opened 10 years ago

conal commented 10 years ago

I've been inlining the method into a selector function and the dictionary and its methods into a large structure, then converting to nested pairs, and then reifying, resulting in enormous beta-redexes. Do the beta-reduction much sooner, but carefully.

conal commented 10 years ago

Addressed via reifyMethod, as part of commit https://github.com/conal/lambda-ccc/commit/8ea54bd22a192ef3e00138f71e0c2029aa22b913: given reifyEP (m d), if m is a variable and d is a dictionary, then anytd inline >>> simplify.

conal commented 10 years ago

Now I see that this strategy doesn't work so well when the dictionary has already been reified, which happens when it's defined in a module that's being reified (either the same module as its use or another one).

Idea: don't reify dictionaries. Then the unreified form will get inlined where used, enabling simplification.

conal commented 10 years ago

Oops. Make unlessDict check that the result is a dictionary. Otherwise, we inline dictionary-constructing functions, which come from instances with constraints, i.e., compound dictionaries.