You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using ghx-exactprint to write ghc type-checked plugin, with ghc-8.10.1. I am testing it over the agda codebase (https://github.com/agda/agda) as it uses a range of GHC features. ghc-exactprint generally does a great job, but there are a couple of cases where it seems not to respect the language extensions, when parsing a file using parseModuleFromString. If instead, I use parseModuleFromStringInternal with the dflags that ghc provides to a plug-in, everything seems to work well.
So I have a work-around, but thought that I'd report the issue, in case there is an underlying problem, rather than a misuse of ghc-exactprint
For example, parseModulefromString doesn't seem to like this
On TypeSynonymInstances, On TupleSections, On StandaloneDeriving,
On ExplicitForAll, On ScopedTypeVariables,
On DisambiguateRecordFields, On RecordWildCards, On ExplicitForAll,
On RankNTypes, On PatternSynonyms, On OverloadedStrings,
On RecordPuns, On MultiWayIf, On ConstrainedClassMethods,
On MultiParamTypeClasses, On LambdaCase,
On ConstrainedClassMethods, On MultiParamTypeClasses,
On FunctionalDependencies, On TypeSynonymInstances,
On FlexibleInstances, On FlexibleContexts, On ExplicitForAll,
On ExistentialQuantification, On DeriveFunctor, On DeriveFoldable,
On DeriveTraversable, On DeriveFunctor, On DeriveFoldable,
On DefaultSignatures, On ConstraintKinds, On BangPatterns]
[On MonoLocalBinds, On KindSignatures, On ExplicitNamespaces,
On TypeFamilies, On NondecreasingIndentation,
On TypeSynonymInstances, On TupleSections, On StandaloneDeriving,
On ExplicitForAll, On ScopedTypeVariables,
On DisambiguateRecordFields, On RecordWildCards, On ExplicitForAll,
On RankNTypes, On PatternSynonyms, On OverloadedStrings,
On RecordPuns, On MultiWayIf, On ConstrainedClassMethods,
On MultiParamTypeClasses, On LambdaCase,
On ConstrainedClassMethods, On MultiParamTypeClasses,
On FunctionalDependencies, On TypeSynonymInstances,
On FlexibleInstances, On FlexibleContexts, On ExplicitForAll,
On ExistentialQuantification, On DeriveFunctor, On DeriveFoldable,
On DeriveTraversable, On DeriveFunctor, On DeriveFoldable,
On DefaultSignatures, On ConstraintKinds, On BangPatterns]
As I am writing a type-checked phase plugin, ghc has parsed the code without complaint. In fact, I am feeding parseModuleFromString with a string generated by lexemeToString applied to ms_hspp_buf modSummary (ie, the pre-processed source).
As I say, the issue appears to be with the DynFlags that parseModuleFromString conjures up. When I use those provided to the plugin (via getDynFlags and parseModuleFromStringInternal) all seems well. Maybe this can be fixed, or the documentation of the contexts in which parseModuleFromString could be supplemented.
[Later]
Maybe spoke too soon. Source comments appear to be discarded when I use parseModulefromStringIntenal
Anyway thanks for the package.
PS: I assume that the a key reason for having ghc-exactprint is that GHC does not retain enough source code annotations, hence the need to reparse the source.
The text was updated successfully, but these errors were encountered:
jrp2014
changed the title
parseModuleFromString seems to guess use unhelpful dflags
parseModuleFromString seems to use unhelpful dflags
May 26, 2020
To answer my own issue, the problem seem to be with the dflags that are set in initDynFlagsPure (perhaps when some language extensions are set in the cabal file, supplemented by language extensions in the source file). If I use the ModSummarydflags but also set Opt_KeepRawTokenStream with parseModuleFromStringInternal it all works OK.
I am using
ghx-exactprint
to write ghc type-checked plugin, with ghc-8.10.1. I am testing it over theagda
codebase (https://github.com/agda/agda) as it uses a range of GHC features.ghc-exactprint
generally does a great job, but there are a couple of cases where it seems not to respect the language extensions, when parsing a file usingparseModuleFromString
. If instead, I useparseModuleFromStringInternal
with thedflags
thatghc
provides to a plug-in, everything seems to work well.So I have a work-around, but thought that I'd report the issue, in case there is an underlying problem, rather than a misuse of
ghc-exactprint
For example,
parseModulefromString
doesn't seem to like thisThe language extentions in use are:
A further case is:
with language extensions (
extensions dflags
)As I am writing a type-checked phase plugin, ghc has parsed the code without complaint. In fact, I am feeding
parseModuleFromString
with a string generated bylexemeToString
applied toms_hspp_buf modSummary
(ie, the pre-processed source).As I say, the issue appears to be with the
DynFlags
thatparseModuleFromString
conjures up. When I use those provided to the plugin (viagetDynFlags
andparseModuleFromStringInternal
) all seems well. Maybe this can be fixed, or the documentation of the contexts in whichparseModuleFromString
could be supplemented.[Later]
Maybe spoke too soon. Source comments appear to be discarded when I use
parseModulefromStringIntenal
Anyway thanks for the package.
PS: I assume that the a key reason for having
ghc-exactprint
is that GHC does not retain enough source code annotations, hence the need to reparse the source.The text was updated successfully, but these errors were encountered: