Add Plinth parsed-AST deriving plugin to plutus-tx-plugin#7818
Draft
Icelandjack wants to merge 1 commit into
Draft
Add Plinth parsed-AST deriving plugin to plutus-tx-plugin#7818Icelandjack wants to merge 1 commit into
Icelandjack wants to merge 1 commit into
Conversation
Icelandjack
marked this pull request as draft
June 16, 2026 12:22
hsyl20
reviewed
Jun 18, 2026
| -- This function is responsible for analyzing a deriving strategy to determine | ||
| -- if the plugin should fire or not. | ||
| parseDerivingStrategy :: | ||
| Maybe (Ghc.LDerivStrategy Ghc.GhcPs) -> Maybe [String] |
Contributor
There was a problem hiding this comment.
Shouldn't it return a Bool?
Comment on lines
+49
to
+59
| flags <- Options.parse Flag.options commandLineOptions srcSpan | ||
| let config = Config.fromFlags flags | ||
|
|
||
| Monad.when (Config.help config) | ||
| . Hsc.throwError srcSpan | ||
| . Ghc.vcat | ||
| . fmap Ghc.text | ||
| . lines | ||
| $ Console.usageInfo ("PlinthPlugin version " <> version) Flag.options | ||
| Monad.when (Config.version config) . Hsc.throwError srcSpan $ | ||
| Ghc.text version |
Contributor
There was a problem hiding this comment.
Why do we need this command-line stuff?
It adds quite a lot of complexity (Paths_ module, Flag, Config) and I'm not sure why?
Comment on lines
+2
to
+4
| -- The plugin-generated code uses 'head'/'tail' internally and emits pattern | ||
| -- synonyms without top-level signatures; suppress those warnings here (the | ||
| -- -Wno-unrecognised-warning-flags keeps -Wno-x-partial harmless pre-GHC 9.8). |
Contributor
There was a problem hiding this comment.
Could we generate explicit pattern matches instead of head/tail?
Could we generate the top-level signatures too?
Author
There was a problem hiding this comment.
Both done in latest push. No head/tail, Match generator and AsData use an explicit pattern. Top-level signatures are generated.
| Ghc.HsTyVar _ _ x -> Just $ Ghc.unLoc x | ||
| _ -> Nothing | ||
| case Ghc.occNameString $ Ghc.rdrNameOcc rdrName of | ||
| "PlinthPlugin" -> Just [] |
Contributor
There was a problem hiding this comment.
Suggested change
| "PlinthPlugin" -> Just [] | |
| "Plinth" -> Just [] |
Users don't care that it is a plugin or not.
Icelandjack
force-pushed
the
baldurb/plinth-deriving-plugin
branch
3 times, most recently
from
July 6, 2026 07:48
9988b8d to
571a34a
Compare
`deriving … via PlinthPlugin` into AsData pattern synonyms, Optics prisms, and Match functions at parse time.
Icelandjack
force-pushed
the
baldurb/plinth-deriving-plugin
branch
from
July 13, 2026 07:50
571a34a to
d490386
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Ports the
PlinthPluginparsed-result plugin from the ghc-plinth "standalonePlinth" effort into
plutus-tx-plugin. It expands data declarations writtenwith
deriving … via PlinthPlugininto:AsDatapattern synonyms (a newtype overBuiltinDataplus bidirectional patterns)OpticsprismsMatchdestructor functionsIt runs at
parsedResultAction, alongside the existing corePlinth.Plugin.The deriving sentinel lives in
PlinthPlugin.Via(data Via = PlinthPlugin).Notes / open items
test-frontend-plugin-style golden test is the natural follow-up.