diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2017-05-19 14:56:09 +0200 |
---|---|---|
committer | Alan Zimmerman <alan.zimm@gmail.com> | 2017-06-06 00:16:20 +0200 |
commit | 8e6ec0fa7431b0454b09c0011a615f0845df1198 (patch) | |
tree | d6b3604e0ceac3d81d0510669f7ccce9a2bf3ae2 /compiler/hsSyn/PlaceHolder.hs | |
parent | c9eb4385aad248118650725b7b699bb97ee21c0d (diff) | |
download | haskell-8e6ec0fa7431b0454b09c0011a615f0845df1198.tar.gz |
Udate hsSyn AST to use Trees that Grow
Summary:
See https://ghc.haskell.org/trac/ghc/wiki/ImplementingTreesThatGrow
This commit prepares the ground for a full extensible AST, by replacing the type
parameter for the hsSyn data types with a set of indices into type families,
data GhcPs -- ^ Index for GHC parser output
data GhcRn -- ^ Index for GHC renamer output
data GhcTc -- ^ Index for GHC typechecker output
These are now used instead of `RdrName`, `Name` and `Id`/`TcId`/`Var`
Where the original name type is required in a polymorphic context, this is
accessible via the IdP type family, defined as
type family IdP p
type instance IdP GhcPs = RdrName
type instance IdP GhcRn = Name
type instance IdP GhcTc = Id
These types are declared in the new 'hsSyn/HsExtension.hs' module.
To gain a better understanding of the extension mechanism, it has been applied
to `HsLit` only, also replacing the `SourceText` fields in them with extension
types.
To preserve extension generality, a type class is introduced to capture the
`SourceText` interface, which must be honoured by all of the extension points
which originally had a `SourceText`. The class is defined as
class HasSourceText a where
-- Provide setters to mimic existing constructors
noSourceText :: a
sourceText :: String -> a
setSourceText :: SourceText -> a
getSourceText :: a -> SourceText
And the constraint is captured in `SourceTextX`, which is a constraint type
listing all the extension points that make use of the class.
Updating Haddock submodule to match.
Test Plan: ./validate
Reviewers: simonpj, shayan-najd, goldfire, austin, bgamari
Subscribers: rwbarton, thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D3609
Diffstat (limited to 'compiler/hsSyn/PlaceHolder.hs')
-rw-r--r-- | compiler/hsSyn/PlaceHolder.hs | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/compiler/hsSyn/PlaceHolder.hs b/compiler/hsSyn/PlaceHolder.hs index 2e195df799..5c716d259c 100644 --- a/compiler/hsSyn/PlaceHolder.hs +++ b/compiler/hsSyn/PlaceHolder.hs @@ -12,14 +12,8 @@ import Name import NameSet import RdrName import Var -import Coercion -import ConLike (ConLike) -import FieldLabel -import SrcLoc (Located) -import TcEvidence ( HsWrapper ) import Data.Data hiding ( Fixity ) -import BasicTypes (Fixity) {- @@ -37,18 +31,6 @@ import BasicTypes (Fixity) data PlaceHolder = PlaceHolder deriving (Data) --- | Types that are not defined until after type checking -type family PostTc id ty -- Note [Pass sensitive types] -type instance PostTc Id ty = ty -type instance PostTc Name ty = PlaceHolder -type instance PostTc RdrName ty = PlaceHolder - --- | Types that are not defined until after renaming -type family PostRn id ty -- Note [Pass sensitive types] -type instance PostRn Id ty = ty -type instance PostRn Name ty = ty -type instance PostRn RdrName ty = PlaceHolder - placeHolderKind :: PlaceHolder placeHolderKind = PlaceHolder @@ -103,31 +85,6 @@ DataId constraint type based on this, so even though it is safe the UndecidableInstances pragma is required where this is used. -} -type DataId id = - ( DataIdPost id - , DataIdPost (NameOrRdrName id) - ) - -type DataIdPost id = - ( Data id - , Data (PostRn id NameSet) - , Data (PostRn id Fixity) - , Data (PostRn id Bool) - , Data (PostRn id Name) - , Data (PostRn id (Located Name)) - , Data (PostRn id [Name]) - - , Data (PostRn id id) - , Data (PostTc id Type) - , Data (PostTc id Coercion) - , Data (PostTc id id) - , Data (PostTc id [Type]) - , Data (PostTc id ConLike) - , Data (PostTc id [ConLike]) - , Data (PostTc id HsWrapper) - , Data (PostTc id [FieldLabel]) - ) - -- |Follow the @id@, but never beyond Name. This is used in a 'HsMatchContext', -- for printing messages related to a 'Match' @@ -135,10 +92,3 @@ type family NameOrRdrName id where NameOrRdrName Id = Name NameOrRdrName Name = Name NameOrRdrName RdrName = RdrName - --- |Constraint type to bundle up the requirement for 'OutputableBndr' on both --- the @id@ and the 'NameOrRdrName' type for it -type OutputableBndrId id = - ( OutputableBndr id - , OutputableBndr (NameOrRdrName id) - ) |