mlabs-haskell / lambda-buffers

LambdaBuffers toolkit for sharing types and their semantics between different languages
https://mlabs-haskell.github.io/lambda-buffers/
Apache License 2.0
29 stars 0 forks source link

Typeclasses & Codegen #25

Closed gnumonik closed 1 year ago

gnumonik commented 1 year ago

This is a refocused version of #8. I'm closing #8 and opening this to help refocus discussion, given that we've split out parts of #8 and almost all of the comments there are outdated in one way or another.

NOTE: I merged in #24 (because I need it to sanity check that things work here). Please direct all discussion of things in lambda-buffers-common to that PR.

NOTE: This needs some cleaning up, which I will do tomorrow. Please focus discussion on the substantive content of the PR and not on (e.g.) missing export lists or disabled warnings or whatever. I promise I'll catch most/all of those tomorrow :P

This PR contains an initial implementation of code generation and typeclass machinery. Here's a brief explanation of the modules:

Common

Gen

Resolve

The typeclass side of things is explained in painstaking detail in the typeclass documentation. Whatever we end up doing for typeclasses is going to have to look something like what I have here.

The codegen side of things, by contrast, was more brainstorm-ey and we might be able to do better. I think what I did ends up being more succinct/ergonomic/reusable than a naive implementation would but eh it needs some input from y'all.

gnumonik commented 1 year ago

ps @bladyjoker I don't understand how to use the new buildAbstraction nix function so I reverted to the old style for codegenBuild. Feel free to fix or lmk how the new thing works