-
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
Optional bootstrapping #175
Optional bootstrapping #175
Conversation
Before this patch, building 'happy' required a pre-built binary of 'happy'. This was elegant in the same way a self-hosting compiler is elegant. But it also made building purely from source more complicated than needed. This patch introduces a small, bespoke parsing library, and applies it for parsing .y and .ly files. Now 'happy' doesn't depend on itself, and can be built using just GHC.
The rationale is basically eating your own dog food. #170 worked well, but it meant that Now this pull request (#175) means we have two implementations at once. I'm afraid that the cure might be worse than the disease, as it will be difficult to keep the two parsers in sync. And it increases the amount of code (thus the amount of potential bugs). Here are the two options that I think are better:
So if we favor inspectability, then #170 is the way to go, because I think my bespoke parser combinators turned out alright. On the other hand, if we favor dogfooding, then we should It's a judgement call. Personally, I favor inspectability more (hence #170). @simonmar told me:
And I didn't execute on that because I'm not that sure that my judgement is correct here. Maybe your vote will determine the outcome here, @Ericson2314 :-) |
@int-index does #170 produce the same parsing code that
|
@int-index I think I am still in favor of this approach. Anything that involves mandatory bootstrapping, without a keeping around build using all happy/alex versions back to the beginning I consider a "coinductive bootstrap". We try to find a fixed point, and cross our fingers it's the right one. By contrast, with #175 allows easy "inductive bootstrap", where you can always boot from the parser combinator version, and therefore compare any fixed point to a "grounded" reference. For reference, I'm a big fan of @taktoa's GHC desiderata in https://gist.github.com/taktoa/a59400fd3e1c400835b60c416ad33952. I view happy and alex also sort of a perfect microcosm of the GHC universe, where we have a chance at checking off these idealistic boxes at far lower cost.
I agree completely.
But think of it as tests! We have in order of clarity: happy output < parser combinators < happy input. So the most auditable spec is the happy input, but the most auditable build artifact is the parser combinator version.
Ah, but we should consider parallel vs serial composition, like with electrical resistance. Bigger implementation is more bugs, but this is 2 implementations. I say this is parallel composition, and thus, like compositing resisters in parallel, means fewer bugs. High-minded reasoning aside, let me offer some concessions:
|
OK, I'm convinced. |
:) Thanks for hearing me out. I suppose I'll wait longer to push the button so @simonmar can weigh in. |
Instead of preprocessing an outer layer of CPP when building happy, just always produce code that uses CPP. Combined with #175, this means happy now has a perfectly bog standard build system, with Makefiles and extra steps strictly optional. I gather Hugs, and possibly other Haskell implementations, out of the box doesn't support CPP, but I don't want this to stop us. Those can just manually run CPP on the generated code first.
We boostrap from source now. Alex is still kept, but just for tests
Should we drop the attribute grammar support from the parser combinators implementation, then? |
@int-index I like it! One small caviet, it might be hard to get Hadrian and Make to do the bootstrap without introducing a stage -1 (ugh), so if GHC uses the attribute grammar stuff I might be tempted to wait to remove it, but if it doesn't then yes let's by all means get rid of it. |
GHC doesn't use it. |
This makes the initial boostrapping stage smaller while not affecting the second stage.
Just out of interest, why not use |
Originally I expected these parser combinators to replace bootstrapping entirely, so I wanted them to be more efficient. Performance considerations influenced their design significantly. But with the new design where they are used to facilitate bootstrapping instead of replacing it, maybe performance isn't important at all. So |
So what say you both that we just merge this so we can also merge #179 and then worry about the |
Yeah, doing one thing at a time sounds reasonable to me. Would you mind squashing the commits before the merge? |
Instead of preprocessing an outer layer of CPP when building happy, just always produce code that uses CPP. Combined with #175, this means happy now has a perfectly bog standard build system, with Makefiles and extra steps strictly optional. I gather Hugs, and possibly other Haskell implementations, out of the box doesn't support CPP, but I don't want this to stop us. Those can just manually run CPP on the generated code first.
This is an alternative to #170 that allow building happy with or without bootstrapping.
The rational here is hidden to me, but I'm hoping that this might be of interest, in that we are both keeping the theoretical niceness of bootstrapping available, while also offering an escape hatch as a first step towards radically simplifying the build system / testing infra of everything happy related. I think the latter is extremely important, because anything at all custom very much hampers the ability of tools like
hadrian
andhaskell.nix
that want to plan and execute a complete bootstrap with as little manual intervention as possible.This is WIP because I need to update CI.Closes #169
CC @angerman @hsyl20