summaryrefslogtreecommitdiff
path: root/compiler/Language/Haskell
diff options
context:
space:
mode:
authorRoss Paterson <R.Paterson@city.ac.uk>2022-09-25 15:33:25 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2022-09-27 14:12:01 -0400
commit9b1595c87f0c2406bb340c5e27a4a45dfcde0e2c (patch)
tree5058b79fa0484c7bb55bfc5515094dff50ae93b2 /compiler/Language/Haskell
parentaeafdba5503b8d26a62dc7bc7078caef170d4154 (diff)
downloadhaskell-9b1595c87f0c2406bb340c5e27a4a45dfcde0e2c.tar.gz
implement proposal 106 (Define Kinds Without Promotion) (fixes #6024)
includes corresponding changes to haddock submodule
Diffstat (limited to 'compiler/Language/Haskell')
-rw-r--r--compiler/Language/Haskell/Syntax/Decls.hs23
1 files changed, 18 insertions, 5 deletions
diff --git a/compiler/Language/Haskell/Syntax/Decls.hs b/compiler/Language/Haskell/Syntax/Decls.hs
index e7c23f84cf..af8c0bb1e9 100644
--- a/compiler/Language/Haskell/Syntax/Decls.hs
+++ b/compiler/Language/Haskell/Syntax/Decls.hs
@@ -16,7 +16,7 @@
{-
(c) The University of Glasgow 2006
-(c) The GRASP/AQUA Project, Glasgow University, 1992-1998
+(c) The GRASP/@type@AQUA Project, Glasgow University, 1992-1998
-}
@@ -33,6 +33,7 @@ module Language.Haskell.Syntax.Decls (
HsDecl(..), LHsDecl, HsDataDefn(..), HsDeriving, LHsFunDep, FunDep(..),
HsDerivingClause(..), LHsDerivingClause, DerivClauseTys(..), LDerivClauseTys,
NewOrData(..), DataDefnCons(..), dataDefnConsNewOrData,
+ isTypeDataDefnCons,
StandaloneKindSig(..), LStandaloneKindSig,
-- ** Class or type declarations
@@ -991,16 +992,28 @@ data NewOrData
| DataType -- ^ @data Blah ...@
deriving ( Eq, Data ) -- Needed because Demand derives Eq
--- | Whether a data-type declaration is `data` or `newtype`, and its constructors
+-- | Whether a data-type declaration is @data@ or @newtype@, and its constructors.
data DataDefnCons a
- = NewTypeCon a -- ^ @newtype Blah ...@
- | DataTypeCons [a] -- ^ @data Blah ...@
+ = NewTypeCon -- @newtype N x = MkN blah@
+ a -- Info about the single data constructor @MkN@
+
+ | DataTypeCons
+ Bool -- True <=> type data T x = ...
+ -- See Note [Type data declarations] in GHC.Rename.Module
+ -- False <=> data T x = ...
+ [a] -- The (possibly empty) list of data constructors
deriving ( Eq, Data, Foldable, Functor, Traversable ) -- Needed because Demand derives Eq
dataDefnConsNewOrData :: DataDefnCons a -> NewOrData
dataDefnConsNewOrData = \ case
NewTypeCon _ -> NewType
- DataTypeCons _ -> DataType
+ DataTypeCons _ _ -> DataType
+
+-- | Are the constructors within a @type data@ declaration?
+-- See Note [Type data declarations] in GHC.Rename.Module.
+isTypeDataDefnCons :: DataDefnCons a -> Bool
+isTypeDataDefnCons (NewTypeCon _) = False
+isTypeDataDefnCons (DataTypeCons is_type_data _) = is_type_data
-- | Located data Constructor Declaration
type LConDecl pass = XRec pass (ConDecl pass)