summaryrefslogtreecommitdiff
path: root/compiler/Language
diff options
context:
space:
mode:
authorromes <rodrigo.m.mesquita@gmail.com>2022-05-23 00:06:32 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-07-06 13:50:27 -0400
commit3547e2640af45ab48187387fb60795a09b662038 (patch)
tree49c9a324698d7b56d1e400c26b417150d9e1938b /compiler/Language
parent86ced2ad8cf6fa1d829b2eea0d2dcbc049bc4a6d (diff)
downloadhaskell-3547e2640af45ab48187387fb60795a09b662038.tar.gz
Prune L.H.S modules of GHC dependencies
Move around datatypes, functions and instances that are GHC-specific out of the `Language.Haskell.Syntax.*` modules to reduce the GHC dependencies in them -- progressing towards #21592 Creates a module `Language.Haskell.Syntax.Basic` to hold basic definitions required by the other L.H.S modules (and don't belong in any of them)
Diffstat (limited to 'compiler/Language')
-rw-r--r--compiler/Language/Haskell/Syntax/Basic.hs45
-rw-r--r--compiler/Language/Haskell/Syntax/Binds.hs64
-rw-r--r--compiler/Language/Haskell/Syntax/Decls.hs6
-rw-r--r--compiler/Language/Haskell/Syntax/Expr.hs6
-rw-r--r--compiler/Language/Haskell/Syntax/Lit.hs48
-rw-r--r--compiler/Language/Haskell/Syntax/Pat.hs50
-rw-r--r--compiler/Language/Haskell/Syntax/Type.hs140
-rw-r--r--compiler/Language/Haskell/Syntax/Type.hs-boot21
8 files changed, 135 insertions, 245 deletions
diff --git a/compiler/Language/Haskell/Syntax/Basic.hs b/compiler/Language/Haskell/Syntax/Basic.hs
new file mode 100644
index 0000000000..ad3e0e94ba
--- /dev/null
+++ b/compiler/Language/Haskell/Syntax/Basic.hs
@@ -0,0 +1,45 @@
+{-# LANGUAGE DeriveDataTypeable #-}
+module Language.Haskell.Syntax.Basic where
+
+import Data.Int (Int)
+
+import Data.Eq
+import Data.Bool
+import Data.Data
+
+
+{-
+************************************************************************
+* *
+Boxity
+* *
+************************************************************************
+-}
+
+data Boxity
+ = Boxed
+ | Unboxed
+ deriving( Eq, Data )
+
+isBoxed :: Boxity -> Bool
+isBoxed Boxed = True
+isBoxed Unboxed = False
+
+{-
+************************************************************************
+* *
+Counts and indices
+* *
+************************************************************************
+-}
+
+-- | The width of an unboxed sum
+type SumWidth = Int
+
+-- | A *one-index* constructor tag
+--
+-- Type of the tags associated with each constructor possibility or superclass
+-- selector
+type ConTag = Int
+
+
diff --git a/compiler/Language/Haskell/Syntax/Binds.hs b/compiler/Language/Haskell/Syntax/Binds.hs
index c50eb7e833..467304af53 100644
--- a/compiler/Language/Haskell/Syntax/Binds.hs
+++ b/compiler/Language/Haskell/Syntax/Binds.hs
@@ -21,8 +21,6 @@ Datatype for: @BindGroup@, @Bind@, @Sig@, @Bind@.
-- See Note [Language.Haskell.Syntax.* Hierarchy] for why not GHC.Hs.*
module Language.Haskell.Syntax.Binds where
-import GHC.Prelude
-
import {-# SOURCE #-} Language.Haskell.Syntax.Expr
( LHsExpr
, MatchGroup
@@ -32,19 +30,18 @@ import {-# SOURCE #-} Language.Haskell.Syntax.Pat
import Language.Haskell.Syntax.Extension
import Language.Haskell.Syntax.Type
-import GHC.Types.Name.Reader(RdrName)
+
import GHC.Types.Basic
-import GHC.Types.SourceText
import GHC.Types.Tickish
-import GHC.Types.Var
import GHC.Types.Fixity
import GHC.Data.Bag
-import GHC.Data.BooleanFormula (LBooleanFormula)
-import GHC.Utils.Outputable
-import GHC.Utils.Panic (pprPanic)
+import GHC.Data.BooleanFormula (LBooleanFormula)
+import GHC.Types.SourceText (StringLiteral)
import Data.Void
+import Data.Bool
+import Data.Maybe
{-
************************************************************************
@@ -372,13 +369,6 @@ data Sig pass
-- 'GHC.Parser.Annotation.AnnDcolon'
| ClassOpSig (XClassOpSig pass) Bool [LIdP pass] (LHsSigType pass)
- -- | A type signature in generated code, notably the code
- -- generated for record selectors. We simply record
- -- the desired Id itself, replete with its name, type
- -- and IdDetails. Otherwise it's just like a type
- -- signature: there should be an accompanying binding
- | IdSig (XIdSig pass) Id
-
-- | An ordinary fixity declaration
--
-- > infixl 8 ***
@@ -435,8 +425,7 @@ data Sig pass
-- 'GHC.Parser.Annotation.AnnInstance','GHC.Parser.Annotation.AnnClose'
-- For details on above see Note [exact print annotations] in GHC.Parser.Annotation
- | SpecInstSig (XSpecInstSig pass) SourceText (LHsSigType pass)
- -- Note [Pragma source text] in GHC.Types.SourceText
+ | SpecInstSig (XSpecInstSig pass) (LHsSigType pass)
-- | A minimal complete definition pragma
--
@@ -447,9 +436,7 @@ data Sig pass
-- 'GHC.Parser.Annotation.AnnClose'
-- For details on above see Note [exact print annotations] in GHC.Parser.Annotation
- | MinimalSig (XMinimalSig pass)
- SourceText (LBooleanFormula (LIdP pass))
- -- Note [Pragma source text] in GHC.Types.SourceText
+ | MinimalSig (XMinimalSig pass) (LBooleanFormula (LIdP pass))
-- | A "set cost centre" pragma for declarations
--
@@ -460,7 +447,6 @@ data Sig pass
-- > {-# SCC funName "cost_centre_name" #-}
| SCCFunSig (XSCCFunSig pass)
- SourceText -- Note [Pragma source text] in GHC.Types.SourceText
(LIdP pass) -- Function name
(Maybe (XRec pass StringLiteral))
-- | A complete match pragma
@@ -471,7 +457,6 @@ data Sig pass
-- complete matchings which, for example, arise from pattern
-- synonym definitions.
| CompleteMatchSig (XCompleteMatchSig pass)
- SourceText
(XRec pass [LIdP pass])
(Maybe (LIdP pass))
| XSig !(XXSig pass)
@@ -490,7 +475,7 @@ isFixityLSig _ = False
isTypeLSig :: forall p. UnXRec p => LSig p -> Bool -- Type signatures
isTypeLSig (unXRec @p -> TypeSig {}) = True
isTypeLSig (unXRec @p -> ClassOpSig {}) = True
-isTypeLSig (unXRec @p -> IdSig {}) = True
+isTypeLSig (unXRec @p -> XSig {}) = True
isTypeLSig _ = False
isSpecLSig :: forall p. UnXRec p => LSig p -> Bool
@@ -526,36 +511,6 @@ isCompleteMatchSig :: forall p. UnXRec p => LSig p -> Bool
isCompleteMatchSig (unXRec @p -> CompleteMatchSig {} ) = True
isCompleteMatchSig _ = False
-hsSigDoc :: Sig name -> SDoc
-hsSigDoc (TypeSig {}) = text "type signature"
-hsSigDoc (PatSynSig {}) = text "pattern synonym signature"
-hsSigDoc (ClassOpSig _ is_deflt _ _)
- | is_deflt = text "default type signature"
- | otherwise = text "class method signature"
-hsSigDoc (IdSig {}) = text "id signature"
-hsSigDoc (SpecSig _ _ _ inl) = (inlinePragmaName . inl_inline $ inl) <+> text "pragma"
-hsSigDoc (InlineSig _ _ prag) = (inlinePragmaName . inl_inline $ prag) <+> text "pragma"
--- Using the 'inlinePragmaName' function ensures that the pragma name for any
--- one of the INLINE/INLINABLE/NOINLINE pragmas are printed after being extracted
--- from the InlineSpec field of the pragma.
-hsSigDoc (SpecInstSig _ src _) = text (extractSpecPragName src) <+> text "instance pragma"
-hsSigDoc (FixSig {}) = text "fixity declaration"
-hsSigDoc (MinimalSig {}) = text "MINIMAL pragma"
-hsSigDoc (SCCFunSig {}) = text "SCC pragma"
-hsSigDoc (CompleteMatchSig {}) = text "COMPLETE pragma"
-hsSigDoc (XSig {}) = text "XSIG TTG extension"
-
--- | Extracts the name for a SPECIALIZE instance pragma. In 'hsSigDoc', the src
--- field of 'SpecInstSig' signature contains the SourceText for a SPECIALIZE
--- instance pragma of the form: "SourceText {-# SPECIALIZE"
---
--- Extraction ensures that all variants of the pragma name (with a 'Z' or an
--- 'S') are output exactly as used in the pragma.
-extractSpecPragName :: SourceText -> String
-extractSpecPragName srcTxt = case (words $ show srcTxt) of
- (_:_:pragName:_) -> filter (/= '\"') pragName
- _ -> pprPanic "hsSigDoc: Misformed SPECIALISE instance pragma:" (ppr srcTxt)
-
{-
************************************************************************
* *
@@ -605,9 +560,6 @@ when we have a different name for the local and top-level binder,
making the distinction between the two names clear.
-}
-instance Outputable (XRec a RdrName) => Outputable (RecordPatSynField a) where
- ppr (RecordPatSynField { recordPatSynField = v }) = ppr v
-
-- | Haskell Pattern Synonym Direction
data HsPatSynDir id
diff --git a/compiler/Language/Haskell/Syntax/Decls.hs b/compiler/Language/Haskell/Syntax/Decls.hs
index da5265a144..0e0f0ff94c 100644
--- a/compiler/Language/Haskell/Syntax/Decls.hs
+++ b/compiler/Language/Haskell/Syntax/Decls.hs
@@ -100,11 +100,13 @@ import {-# SOURCE #-} Language.Haskell.Syntax.Expr
import Language.Haskell.Syntax.Binds
import Language.Haskell.Syntax.Type
+import Language.Haskell.Syntax.Extension
+
import GHC.Hs.Doc -- ROMES:TODO Discuss in #21592 whether this is parsed AST or base AST
+
import GHC.Core.TyCon
import GHC.Types.Basic
import GHC.Types.ForeignCall
-import Language.Haskell.Syntax.Extension
import GHC.Types.Name.Set
import GHC.Types.Fixity
@@ -116,7 +118,7 @@ import GHC.Types.SourceText
import GHC.Core.Type
import GHC.Unit.Module.Warnings
-import GHC.Data.Maybe
+import Data.Maybe
import Data.Data hiding (TyCon,Fixity, Infix)
import Data.Void
diff --git a/compiler/Language/Haskell/Syntax/Expr.hs b/compiler/Language/Haskell/Syntax/Expr.hs
index 8d2a365a8c..6d57489eb5 100644
--- a/compiler/Language/Haskell/Syntax/Expr.hs
+++ b/compiler/Language/Haskell/Syntax/Expr.hs
@@ -25,6 +25,7 @@ module Language.Haskell.Syntax.Expr where
import GHC.Prelude
+import Language.Haskell.Syntax.Basic
import Language.Haskell.Syntax.Decls
import Language.Haskell.Syntax.Pat
import Language.Haskell.Syntax.Lit
@@ -35,7 +36,6 @@ import Language.Haskell.Syntax.Binds
-- others:
import GHC.Core.DataCon (FieldLabelString)
import GHC.Types.Name
-import GHC.Types.Basic
import GHC.Types.Fixity
import GHC.Types.SourceText
import GHC.Types.SrcLoc
@@ -437,8 +437,8 @@ data HsExpr p
-- the expression, (arity - alternative) after it
| ExplicitSum
(XExplicitSum p)
- ConTag -- Alternative (one-based)
- Arity -- Sum arity
+ ConTag -- Alternative (one-based)
+ SumWidth -- Sum arity
(LHsExpr p)
-- | - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnCase',
diff --git a/compiler/Language/Haskell/Syntax/Lit.hs b/compiler/Language/Haskell/Syntax/Lit.hs
index 3000aa345c..a6f3e015b7 100644
--- a/compiler/Language/Haskell/Syntax/Lit.hs
+++ b/compiler/Language/Haskell/Syntax/Lit.hs
@@ -18,18 +18,21 @@
-- | Source-language literals
module Language.Haskell.Syntax.Lit where
-import GHC.Prelude
+import Language.Haskell.Syntax.Extension
-import GHC.Types.Basic (PprPrec(..), topPrec )
+import GHC.Utils.Panic
import GHC.Types.SourceText
import GHC.Core.Type
-import GHC.Utils.Outputable
-import GHC.Utils.Panic
+
import GHC.Data.FastString
-import Language.Haskell.Syntax.Extension
import Data.ByteString (ByteString)
import Data.Data hiding ( Fixity )
+import Data.Bool
+import Data.Ord
+import Data.Eq
+import Data.Char
+import GHC.Integer (Integer) -- ROMES:TODO where is integer
{-
************************************************************************
@@ -147,38 +150,3 @@ instance Ord OverLitVal where
compare (HsIsString _ _) (HsIntegral _) = GT
compare (HsIsString _ _) (HsFractional _) = GT
-instance Outputable OverLitVal where
- ppr (HsIntegral i) = pprWithSourceText (il_text i) (integer (il_value i))
- ppr (HsFractional f) = ppr f
- ppr (HsIsString st s) = pprWithSourceText st (pprHsString s)
-
--- | @'hsLitNeedsParens' p l@ returns 'True' if a literal @l@ needs
--- to be parenthesized under precedence @p@.
-hsLitNeedsParens :: PprPrec -> HsLit x -> Bool
-hsLitNeedsParens p = go
- where
- go (HsChar {}) = False
- go (HsCharPrim {}) = False
- go (HsString {}) = False
- go (HsStringPrim {}) = False
- go (HsInt _ x) = p > topPrec && il_neg x
- go (HsIntPrim _ x) = p > topPrec && x < 0
- go (HsWordPrim {}) = False
- go (HsInt64Prim _ x) = p > topPrec && x < 0
- go (HsWord64Prim {}) = False
- go (HsInteger _ x _) = p > topPrec && x < 0
- go (HsRat _ x _) = p > topPrec && fl_neg x
- go (HsFloatPrim _ x) = p > topPrec && fl_neg x
- go (HsDoublePrim _ x) = p > topPrec && fl_neg x
- go (XLit _) = False
-
--- | @'hsOverLitNeedsParens' p ol@ returns 'True' if an overloaded literal
--- @ol@ needs to be parenthesized under precedence @p@.
-hsOverLitNeedsParens :: PprPrec -> HsOverLit x -> Bool
-hsOverLitNeedsParens p (OverLit { ol_val = olv }) = go olv
- where
- go :: OverLitVal -> Bool
- go (HsIntegral x) = p > topPrec && il_neg x
- go (HsFractional x) = p > topPrec && fl_neg x
- go (HsIsString {}) = False
-hsOverLitNeedsParens _ (XOverLit { }) = False
diff --git a/compiler/Language/Haskell/Syntax/Pat.hs b/compiler/Language/Haskell/Syntax/Pat.hs
index 12ef7ae98a..5846796de4 100644
--- a/compiler/Language/Haskell/Syntax/Pat.hs
+++ b/compiler/Language/Haskell/Syntax/Pat.hs
@@ -27,23 +27,27 @@ module Language.Haskell.Syntax.Pat (
HsRecFields(..), HsFieldBind(..), LHsFieldBind,
HsRecField, LHsRecField,
HsRecUpdField, LHsRecUpdField,
+ RecFieldsDotDot,
hsRecFields, hsRecFieldSel, hsRecFieldsArgs,
) where
-import GHC.Prelude
-
import {-# SOURCE #-} Language.Haskell.Syntax.Expr (SyntaxExpr, LHsExpr, HsUntypedSplice)
-- friends:
+import Language.Haskell.Syntax.Basic
import Language.Haskell.Syntax.Lit
import Language.Haskell.Syntax.Extension
import Language.Haskell.Syntax.Type
-import GHC.Types.Basic
--- others:
-import GHC.Core.Ppr ( {- instance OutputableBndr TyVar -} )
-import GHC.Utils.Outputable
-import GHC.Types.SrcLoc
+
-- libraries:
+import Data.Maybe
+import Data.Functor
+import Data.Foldable
+import Data.Traversable
+import Data.Bool
+import Data.Int
+import Data.Function
+import Data.List
type LPat p = XRec p (Pat p)
@@ -132,7 +136,7 @@ data Pat p
| SumPat (XSumPat p) -- after typechecker, types of the alternative
(LPat p) -- Sum sub-pattern
ConTag -- Alternative (one-based)
- Arity -- Arity (INVARIANT: ≥ 2)
+ SumWidth -- Arity (INVARIANT: ≥ 2)
-- ^ Anonymous sum pattern
--
-- - 'GHC.Parser.Annotation.AnnKeywordId' :
@@ -243,10 +247,12 @@ data HsRecFields p arg -- A bunch of record fields
-- { x = 3, y = True }
-- Used for both expressions and patterns
= HsRecFields { rec_flds :: [LHsRecField p arg],
- rec_dotdot :: Maybe (Located Int) } -- Note [DotDot fields]
+ rec_dotdot :: Maybe (XRec p RecFieldsDotDot) } -- Note [DotDot fields]
-- AZ:The XRec for LHsRecField makes the derivings fail.
-- deriving (Functor, Foldable, Traversable)
+-- Type synonym to be able to have a specific XRec instance for the Int in `rec_dotdot`
+type RecFieldsDotDot = Int
-- Note [DotDot fields]
-- ~~~~~~~~~~~~~~~~~~~~
@@ -353,29 +359,3 @@ hsRecFieldsArgs rbinds = map (hfbRHS . unXRec @p) (rec_flds rbinds)
hsRecFieldSel :: forall p arg. UnXRec p => HsRecField p arg -> XCFieldOcc p
hsRecFieldSel = foExt . unXRec @p . hfbLHS
-
-{-
-************************************************************************
-* *
-* Printing patterns
-* *
-************************************************************************
--}
-
-instance Outputable (HsPatSigType p) => Outputable (HsConPatTyArg p) where
- ppr (HsConPatTyArg _ ty) = char '@' <> ppr ty
-
-instance (Outputable arg, Outputable (XRec p (HsRecField p arg)))
- => Outputable (HsRecFields p arg) where
- ppr (HsRecFields { rec_flds = flds, rec_dotdot = Nothing })
- = braces (fsep (punctuate comma (map ppr flds)))
- ppr (HsRecFields { rec_flds = flds, rec_dotdot = Just (unLoc -> n) })
- = braces (fsep (punctuate comma (map ppr (take n flds) ++ [dotdot])))
- where
- dotdot = text ".." <+> whenPprDebug (ppr (drop n flds))
-
-instance (Outputable p, OutputableBndr p, Outputable arg)
- => Outputable (HsFieldBind p arg) where
- ppr (HsFieldBind { hfbLHS = f, hfbRHS = arg,
- hfbPun = pun })
- = pprPrefixOcc f <+> (ppUnless pun $ equals <+> ppr arg)
diff --git a/compiler/Language/Haskell/Syntax/Type.hs b/compiler/Language/Haskell/Syntax/Type.hs
index e394628f25..9bd8aa90e2 100644
--- a/compiler/Language/Haskell/Syntax/Type.hs
+++ b/compiler/Language/Haskell/Syntax/Type.hs
@@ -30,18 +30,20 @@ module Language.Haskell.Syntax.Type (
LHsQTyVars(..),
HsOuterTyVarBndrs(..), HsOuterFamEqnTyVarBndrs, HsOuterSigTyVarBndrs,
HsWildCardBndrs(..),
- HsPatSigType(..), HsPSRn(..),
+ HsPatSigType(..),
HsSigType(..), LHsSigType, LHsSigWcType, LHsWcType,
HsTupleSort(..),
HsContext, LHsContext,
HsTyLit(..),
HsIPName(..), hsIPNameFS,
- HsArg(..), numVisibleArgs, pprHsArgsApp,
+ HsArg(..),
LHsTypeArg,
LBangType, BangType,
HsSrcBang(..), HsImplBang(..),
SrcStrictness(..), SrcUnpackedness(..),
+ Boxity(..), PromotionFlag(..),
+ isBoxed, isPromoted,
ConDeclField(..), LConDeclField,
@@ -56,29 +58,47 @@ module Language.Haskell.Syntax.Type (
hsPatSigType,
) where
-import GHC.Prelude
-
import {-# SOURCE #-} Language.Haskell.Syntax.Expr ( HsUntypedSplice )
import Language.Haskell.Syntax.Extension
+import Language.Haskell.Syntax.Basic
import GHC.Types.SourceText
-import GHC.Types.Name( Name )
import GHC.Types.Name.Reader ( RdrName )
import GHC.Core.DataCon( HsSrcBang(..), HsImplBang(..),
SrcStrictness(..), SrcUnpackedness(..) )
import GHC.Core.Type
-import GHC.Hs.Doc
-import GHC.Types.Basic
-import GHC.Types.Fixity
import GHC.Types.SrcLoc
-import GHC.Utils.Outputable
-import GHC.Data.FastString
-import GHC.Utils.Misc ( count )
import GHC.Parser.Annotation
+import GHC.Hs.Doc
+import GHC.Data.FastString
+
import Data.Data hiding ( Fixity, Prefix, Infix )
import Data.Void
+import Data.Maybe
+import Data.Eq
+import Data.Bool
+import Data.Char
+import GHC.Num (Integer)
+
+{-
+************************************************************************
+* *
+\subsection{Promotion flag}
+* *
+************************************************************************
+-}
+
+-- | Is a TyCon a promoted data constructor or just a normal type constructor?
+data PromotionFlag
+ = NotPromoted
+ | IsPromoted
+ deriving ( Eq, Data )
+
+isPromoted :: PromotionFlag -> Bool
+isPromoted IsPromoted = True
+isPromoted NotPromoted = False
{-
************************************************************************
@@ -422,14 +442,6 @@ data HsPatSigType pass
}
| XHsPatSigType !(XXHsPatSigType pass)
--- | The extension field for 'HsPatSigType', which is only used in the
--- renamer onwards. See @Note [Pattern signature binders and scoping]@.
-data HsPSRn = HsPSRn
- { hsps_nwcs :: [Name] -- ^ Wildcard names
- , hsps_imp_tvs :: [Name] -- ^ Implicitly bound variable names
- }
- deriving Data
-
-- | Located Haskell Signature Type
type LHsSigType pass = XRec pass (HsSigType pass) -- Implicit only
@@ -680,14 +692,6 @@ newtype HsIPName = HsIPName FastString
hsIPNameFS :: HsIPName -> FastString
hsIPNameFS (HsIPName n) = n
-instance Outputable HsIPName where
- ppr (HsIPName n) = char '?' <> ftext n -- Ordinary implicit parameters
-
-instance OutputableBndr HsIPName where
- pprBndr _ n = ppr n -- Simple for now
- pprInfixOcc n = ppr n
- pprPrefixOcc n = ppr n
-
--------------------------------------------------
-- | Haskell Type Variable Binder
@@ -1081,12 +1085,6 @@ data HsConDetails tyarg arg rec
noTypeArgs :: [Void]
noTypeArgs = []
-instance (Outputable tyarg, Outputable arg, Outputable rec)
- => Outputable (HsConDetails tyarg arg rec) where
- ppr (PrefixCon tyargs args) = text "PrefixCon:" <+> hsep (map (\t -> text "@" <> ppr t) tyargs) <+> ppr args
- ppr (RecCon rec) = text "RecCon:" <+> ppr rec
- ppr (InfixCon l r) = text "InfixCon:" <+> ppr [l, r]
-
{-
Note [ConDeclField passs]
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1203,64 +1201,9 @@ data HsArg tm ty
-- SrcSpan is location of the `@`
| HsArgPar SrcSpan -- See Note [HsArgPar]
-numVisibleArgs :: [HsArg tm ty] -> Arity
-numVisibleArgs = count is_vis
- where is_vis (HsValArg _) = True
- is_vis _ = False
-
-- type level equivalent
type LHsTypeArg p = HsArg (LHsType p) (LHsKind p)
--- | @'pprHsArgsApp' id fixity args@ pretty-prints an application of @id@
--- to @args@, using the @fixity@ to tell whether @id@ should be printed prefix
--- or infix. Examples:
---
--- @
--- pprHsArgsApp T Prefix [HsTypeArg Bool, HsValArg Int] = T \@Bool Int
--- pprHsArgsApp T Prefix [HsTypeArg Bool, HsArgPar, HsValArg Int] = (T \@Bool) Int
--- pprHsArgsApp (++) Infix [HsValArg Char, HsValArg Double] = Char ++ Double
--- pprHsArgsApp (++) Infix [HsValArg Char, HsValArg Double, HsVarArg Ordering] = (Char ++ Double) Ordering
--- @
-pprHsArgsApp :: (OutputableBndr id, Outputable tm, Outputable ty)
- => id -> LexicalFixity -> [HsArg tm ty] -> SDoc
-pprHsArgsApp thing fixity (argl:argr:args)
- | Infix <- fixity
- = let pp_op_app = hsep [ ppr_single_hs_arg argl
- , pprInfixOcc thing
- , ppr_single_hs_arg argr ] in
- case args of
- [] -> pp_op_app
- _ -> ppr_hs_args_prefix_app (parens pp_op_app) args
-
-pprHsArgsApp thing _fixity args
- = ppr_hs_args_prefix_app (pprPrefixOcc thing) args
-
--- | Pretty-print a prefix identifier to a list of 'HsArg's.
-ppr_hs_args_prefix_app :: (Outputable tm, Outputable ty)
- => SDoc -> [HsArg tm ty] -> SDoc
-ppr_hs_args_prefix_app acc [] = acc
-ppr_hs_args_prefix_app acc (arg:args) =
- case arg of
- HsValArg{} -> ppr_hs_args_prefix_app (acc <+> ppr_single_hs_arg arg) args
- HsTypeArg{} -> ppr_hs_args_prefix_app (acc <+> ppr_single_hs_arg arg) args
- HsArgPar{} -> ppr_hs_args_prefix_app (parens acc) args
-
--- | Pretty-print an 'HsArg' in isolation.
-ppr_single_hs_arg :: (Outputable tm, Outputable ty)
- => HsArg tm ty -> SDoc
-ppr_single_hs_arg (HsValArg tm) = ppr tm
-ppr_single_hs_arg (HsTypeArg _ ty) = char '@' <> ppr ty
--- GHC shouldn't be constructing ASTs such that this case is ever reached.
--- Still, it's possible some wily user might construct their own AST that
--- allows this to be reachable, so don't fail here.
-ppr_single_hs_arg (HsArgPar{}) = empty
-
--- | This instance is meant for debug-printing purposes. If you wish to
--- pretty-print an application of 'HsArg's, use 'pprHsArgsApp' instead.
-instance (Outputable tm, Outputable ty) => Outputable (HsArg tm ty) where
- ppr (HsValArg tm) = text "HsValArg" <+> ppr tm
- ppr (HsTypeArg sp ty) = text "HsTypeArg" <+> ppr sp <+> ppr ty
- ppr (HsArgPar sp) = text "HsArgPar" <+> ppr sp
{-
Note [HsArgPar]
~~~~~~~~~~~~~~~
@@ -1276,8 +1219,6 @@ The SrcSpan is the span of the original HsPar
-}
---------------------------------
-
{-
************************************************************************
@@ -1312,17 +1253,6 @@ deriving instance (
, Eq (XXFieldOcc pass)
) => Eq (FieldOcc pass)
-instance Outputable (XRec pass RdrName) => Outputable (FieldOcc pass) where
- ppr = ppr . foLabel
-
-instance (UnXRec pass, OutputableBndr (XRec pass RdrName)) => OutputableBndr (FieldOcc pass) where
- pprInfixOcc = pprInfixOcc . unXRec @pass . foLabel
- pprPrefixOcc = pprPrefixOcc . unXRec @pass . foLabel
-
-instance (UnXRec pass, OutputableBndr (XRec pass RdrName)) => OutputableBndr (GenLocated SrcSpan (FieldOcc pass)) where
- pprInfixOcc = pprInfixOcc . unLoc
- pprPrefixOcc = pprPrefixOcc . unLoc
-
-- | Located Ambiguous Field Occurence
type LAmbiguousFieldOcc pass = XRec pass (AmbiguousFieldOcc pass)
@@ -1350,11 +1280,3 @@ data AmbiguousFieldOcc pass
* *
************************************************************************
-}
-
-instance Outputable HsTyLit where
- ppr = ppr_tylit
---------------------------
-ppr_tylit :: HsTyLit -> SDoc
-ppr_tylit (HsNumTy source i) = pprWithSourceText source (integer i)
-ppr_tylit (HsStrTy source s) = pprWithSourceText source (text (show s))
-ppr_tylit (HsCharTy source c) = pprWithSourceText source (text (show c))
diff --git a/compiler/Language/Haskell/Syntax/Type.hs-boot b/compiler/Language/Haskell/Syntax/Type.hs-boot
new file mode 100644
index 0000000000..126355528a
--- /dev/null
+++ b/compiler/Language/Haskell/Syntax/Type.hs-boot
@@ -0,0 +1,21 @@
+module Language.Haskell.Syntax.Type where
+
+import Data.Bool
+import Data.Eq
+
+{-
+************************************************************************
+* *
+\subsection{Promotion flag}
+* *
+************************************************************************
+-}
+
+-- | Is a TyCon a promoted data constructor or just a normal type constructor?
+data PromotionFlag
+ = NotPromoted
+ | IsPromoted
+
+instance Eq PromotionFlag
+
+isPromoted :: PromotionFlag -> Bool