aristanetworks/purescript-backend-optimizer

Add inline signatures for parameterized dictionaries

natefaubion opened this issue · 1 comments

Currently, it's difficult to anticipate how inlining annotations should work when you instance dictionary takes arguments:

instance myFooBind :: Monoid m => Bind (MyFoo r)
  bind ...

There's no way to attach an inlining annotation to the bind method of this instance. With the compiler's CSE pass, and trivial inlining of the bind dispatch, this will get hoisted to a top-level:

const bind1 = (() => MyFoo.myFooBind(Data$dUnit.unit).bind)();

Prompting some to want to annotate bind1, which is a compiler generated binding. This is not ideal.

Right now, we currently only support annotations referenced by top-level name, or top-level name and accessor. We could also support top-level name, application spine, and accessor, which would let us reference this pattern, and thus bind1 could receive the expected inline annotation without having to reference the compiler generated name for that binding.

Hypothetical directive syntax would probably be something like:

MyFoo.myFooBind(..).bind arity=2

Basically, we need some way to indicate that there should be some application spine between the reference and the method.