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

Get rid of template preprocessing #179

Merged
merged 1 commit into from
Jan 3, 2021
Merged

Conversation

Ericson2314
Copy link
Collaborator

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.

Contains #175 and #178

@int-index
Copy link
Collaborator

I was actually hoping we'd move in the opposite direction w.r.t. CPP, so that the output of happy is proper Haskell, not Haskell+CPP.

Otherwise I don't see how we could achieve #149

@Ericson2314
Copy link
Collaborator Author

Ericson2314 commented Dec 25, 2020

@int-index Well in the short term, I think it's really import that Happy and Alex have "bog standard" build systems so that we can make them submodules in GHC and never have to do things like https://hackage.haskell.org/package/alex-3.2.6/changelog that lead to https://gitlab.haskell.org/ghc/ghc/-/issues/19099 again. And the submodule would allow us to iterate on happy and TH in tandem for #149 too.

Now, I formally thought that CPP was an impediment for #149 too, but I think I have a pretty fun solution for this.
Suppose we follow TTG and instead of having just:

data Dec = ...

we have

data Dec' a = ...
          | XDec a
type Dec = Dec' NoExtCon

Now we can do

[d|
   foo = blah
   bar = blah
   $(XDec $ CppIf "Condition" [d| ... |] CppEndif)
|] :: Dec' Cpp

CPP + TH without polluting TH itself with such a toxin!


Of course, we might still want to get rid of CPP anyways, because it's gross. I don't have a problem with e.g. turning all the templates into quotes that are composed properly on the happy side, but I suspect we'll want that extension to TH anyways.

@simonmar
Copy link
Member

Seems like a good idea.

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.
@Ericson2314 Ericson2314 force-pushed the no-preprocess-data-files branch from 0cfd61e to fa2940f Compare January 3, 2021 15:48
@Ericson2314 Ericson2314 merged commit fa2940f into master Jan 3, 2021
@Ericson2314 Ericson2314 deleted the no-preprocess-data-files branch January 3, 2021 15:50
@Ericson2314 Ericson2314 mentioned this pull request Mar 19, 2021
6 tasks
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.

3 participants