Constructor wrappers vs workers in generated Core
Matthew Pickering
matthewtpickering at gmail.com
Mon Feb 4 17:56:49 UTC 2019
If you want your core to look at much like the source program as
possible then you could print `$WFoo` as just `Foo`?
The existence of wrappers is a crucial part of desugaring so perhaps
it's useful for users to see them in the output of your program if
it's intended to be educational?
Matt
On Sat, Feb 2, 2019 at 3:06 PM Christopher Done <chrisdone at gmail.com> wrote:
>
> On Sat, 2 Feb 2019 at 14:50, Matthew Pickering
> <matthewtpickering at gmail.com> wrote:
> > There is no way to turn off wrappers and I don't think it would be
> > possible to implement easily if at all.
>
> Fair enough.
>
> > However, they will all probably be inlined after the optimiser runs
> > but it seems that you don't want to run the optimiser at all on the
> > generated core?
>
> Yeah, I'm trying to avoid as much instability in the output shape as
> possible, and for educational purposes, optimizations make fairly
> readable code unreadable.
>
> Wait. Can I rely on case alt patterns having the same arity as the
> original user-defined data type before optimization passes are run?
>
> If the answer to that is yes, then I could just replace all wrapper
> calls with worker calls, which is an easy enough transformation. As a
> precaution, I could add a check on all case alt patterns that the
> arity matches the worker arity and barf if not.
>
> Thanks for your help!
>
> Chris
More information about the ghc-devs
mailing list