shayne-fletcher / ghc-lib-parser-ex Goto Github PK
View Code? Open in Web Editor NEWGHC API parse tree utilities
License: Other
GHC API parse tree utilities
License: Other
Using GHC-9.0,1, ghc-lib-parser-9.0.2.20211226 and ghc-lib-parser-ex-9.0.0.6
Is there are a guide how to not run into problems like these?
• Couldn't match expected type ‘GHC.Settings.Settings’
with actual type ‘ghc-9.0.1:GHC.Settings.Settings’
NB: ‘GHC.Settings.Settings’
is defined in ‘GHC.Settings’
in package ‘ghc-lib-parser-9.0.2.20211226’
‘ghc-9.0.1:GHC.Settings.Settings’
is defined in ‘GHC.Settings’ in package ‘ghc-9.0.1’
and the code is
import GHC.Driver.Session (DynFlags, defaultDynFlags, xopt_set)
import Language.Haskell.GhclibParserEx.GHC.Settings.Config (fakeLlvmConfig, fakeSettings)
fakeDynFlags :: DynFlags
fakeDynFlags = defaultDynFlags fakeSettings fakeLlvmConfig
Is there are a guide how to not run into problems like these?
I find it surprising that ghc-lib-parser-ex
depends on ghc
lib, it's ghc-lib-parser-ex! Do I need to replicate flag logic to depend on ghc
lib myself too? duh.
See PR ndmitchell/hlint#1043 for details.
I'm seeing build errors when building ghc-lib-parser-ex 8.8.5.2 against ghc-lib-parser 8.8.2.20200205.
ghc_lib_parser_ex/v8_8_5_2/src/Language/Haskell/GhclibParserEx/DynFlags.hs:31:50: error:
• No instance for (Bounded Extension)
arising from a use of ‘minBound’
There are instances for similar types:
instance [safe] Bounded
ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension
-- Defined in ‘ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type’
• In the expression: minBound
In the expression: [minBound .. maxBound]
In a stmt of a list comprehension: x <- [minBound .. maxBound]
|
31 | where exts = Map.fromList [(show x, x) | x <- [minBound .. maxBound]]
| ^^^^^^^^
ghc_lib_parser_ex/v8_8_5_2/src/Language/Haskell/GhclibParserEx/DynFlags.hs:142:41: error:
• Couldn't match type ‘Extension’
with ‘ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension’
NB: ‘ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension’
is defined in ‘GHC.LanguageExtensions.Type’
in package ‘ghc-lib-parser-8.8.2.20200205’
‘Extension’
is defined in ‘GHC.LanguageExtensions.Type’
in package ‘ghc-boot-th-8.6.4’
Expected type: [ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension]
Actual type: [Extension]
• In the third argument of ‘foldl'’, namely ‘enable’
In the expression: foldl' xopt_set flags enable
In an equation for ‘flags'’: flags' = foldl' xopt_set flags enable
|
142 | let flags' = foldl' xopt_set flags enable
| ^^^^^^
ghc_lib_parser_ex/v8_8_5_2/src/Language/Haskell/GhclibParserEx/DynFlags.hs:143:44: error:
• Couldn't match type ‘Extension’
with ‘ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension’
NB: ‘ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension’
is defined in ‘GHC.LanguageExtensions.Type’
in package ‘ghc-lib-parser-8.8.2.20200205’
‘Extension’
is defined in ‘GHC.LanguageExtensions.Type’
in package ‘ghc-boot-th-8.6.4’
Expected type: [ghc-lib-parser-8.8.2.20200205:GHC.LanguageExtensions.Type.Extension]
Actual type: [Extension]
• In the third argument of ‘foldl'’, namely ‘disable’
In the expression: foldl' xopt_unset flags' disable
In an equation for ‘flags''’:
flags'' = foldl' xopt_unset flags' disable
|
143 | let flags'' = foldl' xopt_unset flags' disable
| ^^^^^^^
Remove GhclibParserEx.Parse.hs
and GhclibParserEx.Outputable.hs
when we get to up to 8.10.2
.
While we wait for MR #2654 to be merged upstream, provide the listed constants of the issue title in Language.Haskell.GhclibParserEx.DynFlags
. When generally available, the implementations can be replaced by redirections to the GHC API. See ndmitchell/hlint#587 for the motivation.
cbits\ghclib_api.h:28:10: error:
error: #error Unsupported GHC API version
# error Unsupported GHC API version
^~~~~
|
28 | # error Unsupported GHC API version
| ^
`gcc.exe' failed in phase `C pre-processor'. (Exit code: 1)
Trying to compile with 9.2.1 fails:
Preprocessing library for ghc-lib-parser-ex-9.0.0.4..
Building library for ghc-lib-parser-ex-9.0.0.4..
[ 1 of 20] Compiling Language.Haskell.GhclibParserEx.Dump
[ 2 of 20] Compiling Language.Haskell.GhclibParserEx.Fixity
src/Language/Haskell/GhclibParserEx/Fixity.hs:213:11: error:
Not in scope: type constructor or class ‘FixityDirection’
|
213 | fixity :: FixityDirection -> Int -> [String] -> [(String, Fixity)]
| ^^^^^^^^^^^^^^^
src/Language/Haskell/GhclibParserEx/Fixity.hs:228:48: error:
Not in scope: data constructor ‘Fixity’
Perhaps you meant one of these:
variable ‘fixity’ (line 214),
variable ‘fdFixity’ (imported from GHC.Hs)
|
228 | f (L _ (SigD _ (FixSig _ (FixitySig _ ops (Fixity _ p dir))))) =
| ^^^^^^
Would be great if this had a Bounded instance. Probably best upstream?
strToPat
return an LPat GhcPs
parseExpression
return a ParseResult (LHsExpr GhcPs)
readExtension
in those places where it defines it inline.[ 44s] + ./Setup build -v
[ 44s] Component build order: library
[ 44s] /usr/bin/ghc-pkg init dist/package.conf.inplace
[ 44s] creating dist/build
[ 44s] creating dist/build/autogen
[ 44s] creating dist/build/autogen
[ 44s] Preprocessing library for ghc-lib-parser-ex-9.0.0.3..
[ 44s] Building library for ghc-lib-parser-ex-9.0.0.3..
[ 44s] creating dist/build
[ 44s] /usr/bin/ghc --make -fbuilding-cabal-package -O -static -dynamic-too -dynosuf dyn_o -dynhisuf dyn_hi -outputdir dist/build -odir dist/build -hidir dist/build -stubdir dist/build -i -idist/build -isrc -idist/build/autogen -idist/build/global-autogen -Idist/build/autogen -Idist/build/global-autogen -Idist/build -Icbits -Idist/build/cbits -optP-include -optPdist/build/autogen/cabal_macros.h -this-unit-id ghc-lib-parser-ex-9.0.0.3-7vv2xbG2Jdb5CGJuwY2m7Q -hide-all-packages -Wmissing-home-modules -no-user-package-db -package-db dist/package.conf.inplace -package-id base-4.15.0.0 -package-id bytestring-0.10.12.1 -package-id containers-0.6.4.1 -package-id ghc-9.0.1 -package-id ghc-boot-9.0.1 -package-id ghc-boot-th-9.0.1 -package-id uniplate-1.6.13-6yuzA7Q8NEEtlEJ9JXZaY -XHaskell2010 Language.Haskell.GhclibParserEx.Dump Language.Haskell.GhclibParserEx.Fixity Language.Haskell.GhclibParserEx.GHC.Settings.Config Language.Haskell.GhclibParserEx.GHC.Driver.Flags Language.Haskell.GhclibParserEx.GHC.Driver.Session Language.Haskell.GhclibParserEx.GHC.Hs Language.Haskell.GhclibParserEx.GHC.Hs.Expr Language.Haskell.GhclibParserEx.GHC.Hs.Pat Language.Haskell.GhclibParserEx.GHC.Hs.Types Language.Haskell.GhclibParserEx.GHC.Hs.Decls Language.Haskell.GhclibParserEx.GHC.Hs.Binds Language.Haskell.GhclibParserEx.GHC.Hs.ImpExp Language.Haskell.GhclibParserEx.GHC.Hs.ExtendInstances Language.Haskell.GhclibParserEx.GHC.Parser Language.Haskell.GhclibParserEx.GHC.Types.Name.Reader Language.Haskell.GhclibParserEx.GHC.Utils.Outputable Language.Haskell.GhclibParserEx.Config Language.Haskell.GhclibParserEx.Parse Language.Haskell.GhclibParserEx.Outputable Paths_ghc_lib_parser_ex -optc-O2 -optc-Wall '-optc-D_FORTIFY_SOURCE=2' -optc-fstack-protector-strong -optc-funwind-tables -optc-fasynchronous-unwind-tables -optc-fstack-clash-protection '-optc-Werror=return-type'
[ 44s] [ 1 of 20] Compiling Language.Haskell.GhclibParserEx.Dump ( src/Language/Haskell/GhclibParserEx/Dump.hs, dist/build/Language/Haskell/GhclibParserEx/Dump.o, dist/build/Language/Haskell/GhclibParserEx/Dump.dyn_o )
[ 44s]
[ 44s] src/Language/Haskell/GhclibParserEx/Dump.hs:23:1: error:
[ 44s] Could not find module ‘HsDumpAst’
[ 44s] Use -v (or `:set -v` in ghci) to see a list of the files searched for.
[ 44s] |
[ 44s] 23 | import HsDumpAst
[ 44s] | ^^^^^^^^^^^^^^^^
[ 44s] error: Bad exit status from /var/tmp/rpm-tmp.QOoMrn (%build)
[ 44s]
[ 44s]
I get:
Failed to install ghc-lib-parser-8.10.1.20200324
Build log ( /home/travis/.cabal/logs/ghc-8.4.4/ghc-lib-parser-8.10.1.20200324-DD7WEZv1DLv8XvMI2yfjnH.log ):
cabal: Entering directory '/tmp/cabal-tmp-11429/ghc-lib-parser-8.10.1.20200324'
Configuring ghc-lib-parser-8.10.1.20200324...
Preprocessing library for ghc-lib-parser-8.10.1.20200324..
In file included from /usr/include/_G_config.h:15:0,
from /usr/include/libio.h:31,
from /usr/include/stdio.h:74,
from /opt/ghc/8.4.4/lib/ghc-8.4.4/include/rts/Flags.h:16,
from /opt/ghc/8.4.4/lib/ghc-8.4.4/include/Rts.h:191,
from InfoTable.hsc:8:
InfoTable.hsc: In function ‘main’:
/opt/ghc/8.4.4/lib/ghc-8.4.4/template-hsc.h:75:24: error: ‘struct StgInfoTable_’ has no member named ‘srt’
(long) offsetof (t, f));
^
InfoTable.hsc:41:5: note: in expansion of macro ‘hsc_peek’
/opt/ghc/8.4.4/lib/ghc-8.4.4/template-hsc.h:79:24: error: ‘StgInfoTable {aka struct StgInfoTable_}’ has no member named ‘srt’
(long) offsetof (t, f));
^
InfoTable.hsc:59:5: note: in expansion of macro ‘hsc_poke’
compiling dist/build/GHC/Exts/Heap/InfoTable_hsc_make.c failed (exit code 1)
From https://travis-ci.org/github/ndmitchell/hlint/jobs/668189975
Are we going to have to ditch GHC 8.4 support?
... which is sad, but I understand your constraints.
Should patToStr
print the var if the input is a VarPat
, so that patToStr . strToPar == id
?
Hi, we are trying to add support for ghc-9.0.2 in hls here: haskell/haskell-language-server#2567
The cabal build of ghc-lib-parser-ex-9.0.0.6
is succesful but the stack one is failing with several errors like:
ghc-lib-parser-ex > /tmp/stack-f10fe8295758b94c/ghc-lib-parser-ex-9.0.0.6/src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs:59:20: error:
ghc-lib-parser-ex > Ambiguous occurrence ‘PlatformMisc’
ghc-lib-parser-ex > It could refer to
ghc-lib-parser-ex > either ‘GHC.Settings.PlatformMisc’,
ghc-lib-parser-ex > imported from ‘GHC.Settings’ at src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs:19:1-19
ghc-lib-parser-ex > (and originally defined in ‘ghc-boot-9.0.2:GHC.Platform’)
ghc-lib-parser-ex > or ‘GHC.Platform.PlatformMisc’,
ghc-lib-parser-ex > imported from ‘GHC.Platform’ at src/Language/Haskell/GhclibParserEx/GHC/Settings/Config.hs:18:1-19
ghc-lib-parser-ex > |
ghc-lib-parser-ex > 59 | platformMisc = PlatformMisc {}
ghc-lib-parser-ex > |
Errors are all related with platform*
definitions.
It may be a error in out stack.yaml but i am not getting to identify it, thanks in advance
Add a predicate for whether an import uses QualifiedPost (ndmitchell/hlint#1070).
It's defined in Data.Function
.
Can I send a PR for this?
Perhaps this library is too low-level, but I'd like to be able to build an app that
GHC can be coaxed into generating a nicely-formatted set of minimal imports (by -ddump-minimal-imports) so presumably this library can get at them somehow and update the sources, ideally preserving comments using some heuristic.
Those imports across a project can then be used to generate a minimal list of exports.
I think that this would be helpful for detecting and minimising cruft in old codebases.
Any pointers to where to start would be gratefully received. Perhaps the app would make a good demo for the library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.