WIP: use prettyprinter rather than ghc-source-gen#522
WIP: use prettyprinter rather than ghc-source-gen#522TeofilC wants to merge 1 commit intogoogle:masterfrom
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
I have created a shim that uses prettyprinter to reimplement the bits of the ghc-source-gen interface we use. It's currently horribly broken but stuff compiles so that's a start! Then I will work to get rid of this shim. |
|
|
||
|
|
||
| module' :: Maybe ModuleNameStr -> Maybe [IE'] -> [ImportDecl'] -> [HsDecl'] -> HsModule' | ||
| module' (Just nm) (mexports) imports decls = |
Check warning
Code scanning / HLint
Redundant bracket Warning
| Right fs -> preamble & #file .~ | ||
| [ defMessage | ||
| & #name .~ outputName | ||
| & #name .~ (traceShowId outputName) |
Check notice
Code scanning / HLint
Redundant bracket Note
Good start! I see that ghc-9.10 can compile the PR, the older versions still need more work. |
5b96e63 to
c52a71e
Compare
|
Good spot. They changed the module names in a recent version. I'll switch back to the old names so that the versions from those snapshots will work. |
c52a71e to
b2554e3
Compare
| pretty ImportDecl{..} = | ||
| hsep $ | ||
| ["import"] | ||
| ++ (if isSource then ["{-# SOURCE #-}"] else []) |
Check notice
Code scanning / HLint
Use list comprehension Note
| hsep $ | ||
| ["import"] | ||
| ++ (if isSource then ["{-# SOURCE #-}"] else []) | ||
| ++ (if isQualified then ["qualified"] else []) |
Check notice
Code scanning / HLint
Use list comprehension Note
| ++ (if isQualified then ["qualified"] else []) | ||
| ++ [pretty ideclName] | ||
| ++ es | ||
| ++ (maybe [] (\as -> ["as", pretty as]) ideclAs) |
Check notice
Code scanning / HLint
Redundant bracket Note
| unit = "()" | ||
|
|
||
| if' :: Doc' -> Doc' -> Doc' -> Doc' | ||
| if' c y n = "if" <+> c <+> "then" <+> (nest 2 (line <> y) <> line) <+> "else" <+> (nest 2 (line <> n)) |
Check notice
Code scanning / HLint
Redundant bracket Note
| strict :: Doc' -> Doc' | ||
| strict x = "!" <> parens x | ||
|
|
||
| tyApp lhs rhs = lhs <+> "@" <> (parens rhs) |
Check notice
Code scanning / HLint
Redundant bracket Note
No description provided.