-
Notifications
You must be signed in to change notification settings - Fork 84
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
Split out happy-codegen-common #221
Conversation
I’m fine with splitting out a data type, but I think that making it a separate package is overkill. Nothing stops us from making a separate package for every data type and every function, and then we could be really explicit about what depends on what, but there’s a cost to this: uploading more packages to Hackage, maintaining correct version bounds, cluttering the dependency graph for end-users, etc. I actually think the separation between There’s a trade-off between fine-grained and coarse-grained dependencies, and I’d like our decisions to be informed by (at least imaginary) use cases:
|
To elaborate a bit more on this, packages are a means of code distribution, and should be motivated by distribution needs. As long as we ship The backends go into their own packages because we could easily ship Now, what this patch is doing is related to separation of concerns rather than distribution. And I’m more than happy to separate concerns: dedicated functions, data types, and modules, are all very good (that is also the stated motivation: “make each data type shine on its own”). But there’s no need for separate |
@int-index I agree we don't want to go overkill on the packages, and indeed it's already unwieldy. But, I do think there is some utility in ripping things into too many pieces on purpose, just so you have a clean slate and more flexibility to decide to decide how to to put them back together. I agree with your breakdown of concerns and survey of potential distributions. I agree too it is likely As far as concerns go, this stuff is really backend concerns that need an interface so we show-horn them in the frontend. The core middle parts of the compiler (which I think are destined to become the most general-purpose librar(y|ies)) don't care about them at all. As far as distributions go, I think use-case: along these lines are useful and plausible:
All of these would avoid the frontend, avoid the CLI, avoid the backends, and avoid this I think a likely happy ending for How does that sound? |
Yes, sounds reasonable overall. But if you put the directives in |
I think that's not so bad, because the current frontend is specific to the use-cases that do codegen. |
edd8d35
to
71edaaf
Compare
There was some extra information stuff in `Grammar` which had nothing to do with the grammar, but was simply there because `Grammar` was also playing the role of capturing all information from the abstract syntax. I don't think that's good. As we really try to really make libraries out of this stuff we should be stricter and stricter about separating concerns. Grammar should really just be that, the grammar, and the code in `happy-tabular` should not be privy to information that is just for the backend. Splitting out a code generation `CommonOptions` type is a first step to rectifying this. I hope we can do a few more refactors like this to really make each data type shine on its own. --- I don't want to sound to harsh though, since we purposely made the split low impact with more cleanups -- such as this -- left for later. It is of course easier to see what's good and what's bad once the code is split up! Also, this change calls into question my previous `BookendedAbsSyn`. We're now acknowledging the abstract syntax mixes "middle" and back end concerns, and those are not properly separated until the nest step. Given that, there isn't much use of making `BookendedAbsSyn` when we could just stick the header and footer in `CommonOptions`.
This temporarily undoes the patch
71edaaf
to
b6910c3
Compare
> token_type :: String, | ||
> imported_identity :: Bool, | ||
> monad :: (Bool,String,String,String,String), | ||
> expect :: Maybe Int, | ||
> attributes :: [(String,String)], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn’t attribute
and attributetypes
also move to CommonOptions
? They’re not used by happy-tabular
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes they should be moved out, but I figured I would deal with all attribute things in the next PR.
Also I vaguely recall only one backend supported attribute grammars?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think GLR doesn’t.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK Yeah so the attributes stuff should be moved out to a different data type, and with that change we should get some better errors if one tries to do attribute stuff with the GLR backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t know if GLR and attributes are fundamentally incompatible or if it’s a limitation of the current backend. In the latter case, we should probably still pass the attribute stuff to the backend and throw “NotImplemented” or something of this sort.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy’s documentation is unhelpfully vague on this point:
Currently, attribute grammars cannot be generated for GLR parsers (It's not exactly clear how these features should interact...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I think if we had a separate datatype, the lack of attribute grammars during bootstrapping could perhaps become a little cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@int-index between boostrapping and the uncertainty around GLR, are you fine leaving it as-is for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, fine with me. I was concerned that happy-directives
is too fine-grained, but happy-codegen-common
is reasonable.
There was some extra information stuff in
Grammar
which had nothing todo with the grammar, but was simply there because
Grammar
was alsoplaying the role of capturing all information from the abstract syntax.
I don't think that's good. As we really try to really make libraries out
of this stuff we should be stricter and stricter about separating
concerns. Grammar should really just be that, the grammar, and the code
in
happy-tabular
should not be privy to information that is just forthe backend.
Splitting out a code generation
CommonOptions
type is a first step to rectifying this. Ihope we can do a few more refactors like this to really make each data
type shine on its own.
I don't want to sound to harsh though, since we purposely made the split
low impact with more cleanups -- such as this -- left for later. It is
of course easier to see what's good and what's bad once the code is
split up!
Also, this change calls into question my previous
BookendedAbsSyn
.We're now acknowledging the abstract syntax mixes "middle" and back end
concerns, and those are not properly separated until the nest step.
Given that, there isn't much use of making
BookendedAbsSyn
when wecould just stick the header and footer in
CommonOptions
.