Skip to content

Switch from template-haskell to template-haskell-lift#717

Open
TeofilC wants to merge 1 commit intohaskell:masterfrom
TeofilC:wip/th-lift
Open

Switch from template-haskell to template-haskell-lift#717
TeofilC wants to merge 1 commit intohaskell:masterfrom
TeofilC:wip/th-lift

Conversation

@TeofilC
Copy link
Copy Markdown
Member

@TeofilC TeofilC commented Oct 10, 2025

We switch our dependency on template-haskell to a dependency on template-haskell-lift. This smaller library is more stabler. If we can remove the template-haskell dependency from all boot libraries then template-haskell will be much easier to re-install since it no longer needs to be in GHC's dependency closure.

For more information see the GHC proposal that introduced this library: ghc-proposals/ghc-proposals#696

This GHC MR tests this PR against GHC-HEAD: https://gitlab.haskell.o

@TeofilC TeofilC changed the title Wip/th lift Switch from template-haskell to template-haskell-lift Oct 10, 2025
@TeofilC TeofilC force-pushed the wip/th-lift branch 4 times, most recently from 54ef253 to d85e62d Compare October 10, 2025 17:40
@Bodigrim
Copy link
Copy Markdown
Contributor

We strive for new releases to be backportable to older GHC major series, which do not yet have template-haskell-lift as a boot library. To keep it possible, I imagine you need something like

if impl(ghc>9.15)
  build-depends: template-haskell-lift
else 
  build-depends: template-haskell 

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Oct 10, 2025

Good point. template-haskell-lift itself is buildable with older major versions (where it just re exports tenplate-haskell) but unless we backport it as a boot library to those versions then indeed you wouldn't be able to use the new bytestring as a boot library.

I'll implement what you suggest

@TeofilC TeofilC force-pushed the wip/th-lift branch 3 times, most recently from e1fb704 to 800ee4c Compare October 12, 2025 11:22
@Bodigrim
Copy link
Copy Markdown
Contributor

@TeofilC please rebase.

@Bodigrim
Copy link
Copy Markdown
Contributor

@TeofilC could you please raise a draft GHC MR, which updates bytestring submodule to your commit? Otherwise I cannot test it.

@TeofilC TeofilC force-pushed the wip/th-lift branch 2 times, most recently from afc9dd0 to 99ec2e9 Compare October 16, 2025 22:58
@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Jan 10, 2026

Since I last looked at this, bytestring has gained a dependency on liftCode. This is not exposed by template-haskell-lift, so for now this PR is stalled.

This shows a gap in the interface of template-haskell-lift. Exporting unsafeCodeCoerce from template-haskell-lift should allow this code to be written. I didn't spot this when designing the interface since so few people use the typed TH API, but this is a reasonable thing to want.

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Jan 10, 2026

Actually we can just use error and we get a similar message!

@TeofilC TeofilC force-pushed the wip/th-lift branch 4 times, most recently from 754b7a7 to ee19745 Compare January 10, 2026 22:06
@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Jan 10, 2026

Not sure about the CI failure on 9.0. I can't reproduce it locally

@TeofilC TeofilC marked this pull request as ready for review January 10, 2026 22:14
@Bodigrim
Copy link
Copy Markdown
Contributor

Not sure about the CI failure on 9.0. I can't reproduce it locally

It's unrelated to your changes, I have the same failure in #718 (comment).

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Mar 10, 2026

Anything I can do to move this along ?

@Bodigrim
Copy link
Copy Markdown
Contributor

@TeofilC if you have time to figure out what’s up with the CI, it would help to speed things up.

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Apr 3, 2026

I tried to have a quick look but had little luck. I tried building locally with GHC-9.0.2 and it seems to run the test suite fine.

Perhaps it's something like a broken cache or some oddness about the github runner env?

@Bodigrim
Copy link
Copy Markdown
Contributor

Bodigrim commented Apr 3, 2026

Could you rebase and trigger a fresh CI run?

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Apr 3, 2026

Interesting now we are getting this failure on 9.2. When running it locally, I was getting this too:

 *** Failed! Exception: './lazy-hclose-test7457-300.tmp: withFile: resource busy (file is locked)' 

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Apr 3, 2026

I see fixed on the other PR

@Bodigrim
Copy link
Copy Markdown
Contributor

Bodigrim commented Apr 3, 2026

There seems to be a bunch of warnings "The import of ‘Language.Haskell.TH.Syntax’ is redundant" for GHC < 9.14.

@TeofilC
Copy link
Copy Markdown
Member Author

TeofilC commented Apr 3, 2026

There seems to be a bunch of warnings "The import of ‘Language.Haskell.TH.Syntax’ is redundant" for GHC < 9.14.

Fixed now, we only needed that import before <9.0

@Bodigrim Bodigrim requested review from clyring, hsyl20 and sjakobi April 12, 2026 17:09
This new boot library should be more stable than template-haskell and
should eventually allow us to remove much of the CPP around TH.

It will also make it easier for end-users to reinstall template-haskell
as it will no longer be used by any boot libraries
Copy link
Copy Markdown
Contributor

@hsyl20 hsyl20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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.

4 participants