lambda-ccc icon indicating copy to clipboard operation
lambda-ccc copied to clipboard

Convenient cross-module reification

Open conal opened this issue 11 years ago • 0 comments

Inter-module access to reified definitions is a bit tricky. So far module interfaces are kept intact, including type signatures. Since reification produces a different type (reifyE :: a -> E p a), this constraint means that no reified definitions can be exported. Instead, we wrap a reified expression in a evalE call. The idea is to inline that definition elsewhere, in the context of applying reifyE, hoping that the reifyE/evalE rewrite rule will kick in. In order to reduce the amount of inlining required, there's a second trick. Split foo = evalE ... into foo_reified = ... and foo = evalE foo_reified. We need only inline this short foo definition to get the reifyE/evalE rule to fire.

I've been unable to get the required inlining and simplification to happen in a client module (i.e., one using a reified module), however, without specially handling that module as well.

The rewrite rule trick gives indirect access to the unexported foo_reified definitions via reifyE foo. Look for more robust alternatives.

conal avatar Apr 13 '14 16:04 conal