Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idempotence & version bounds tweak #159

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

isaac-uptrust
Copy link

@isaac-uptrust isaac-uptrust commented Aug 9, 2024

large-records has been really helpful. We have a fairly big beam schema, and when combined with beam-automigrate compilation ran out of memory on an 8GB system. With a large-records schema, the peak memory usage during compilation is ~2.5GB.

Plugin idempotence

When I used large-records in GHCi1 I found that the plugin fired twice, feeding the output from the first run into the second run. I got an error, because the output of the first run is an invalid large-records declaration. This change removes the annotation when the large-records declaration is processed, so that subsequent runs don't try to transform already-transformed datatypes.

primitive version bounds

We're stuck with an older version of primitive, and large-records seems to work with it.

Footnotes

  1. We're using Obelisk to launch GHCi. I noticed that Obelisk uses a syntax preprocessor (-pgmF); I wonder if that has something to do with it.

It's possible for the compiler plugin to fire multiple times, with
each successive run using the AST from the previous run.

When this happens, the first run succeeds but later runs fail. The
datatype definition generated by `transformDecl` still has the
`largeRecord` annotation, but is no longer in a form that's accepted
by the compiler plugin.

Removing the annotations for which `transformDecl` succeeds makes the
compiler plugin idempotent.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant