diff options
Diffstat (limited to 'compiler/Language/Haskell')
-rw-r--r-- | compiler/Language/Haskell/Syntax/Expr.hs | 4 | ||||
-rw-r--r-- | compiler/Language/Haskell/Syntax/Extension.hs | 13 | ||||
-rw-r--r-- | compiler/Language/Haskell/Syntax/Pat.hs | 3 |
3 files changed, 20 insertions, 0 deletions
diff --git a/compiler/Language/Haskell/Syntax/Expr.hs b/compiler/Language/Haskell/Syntax/Expr.hs index 6f5150a1b4..b4d7b24dea 100644 --- a/compiler/Language/Haskell/Syntax/Expr.hs +++ b/compiler/Language/Haskell/Syntax/Expr.hs @@ -404,7 +404,9 @@ data HsExpr p -- For details on above see note [exact print annotations] in GHC.Parser.Annotation | HsPar (XPar p) + !(LHsToken "(" p) (LHsExpr p) -- ^ Parenthesised expr; see Note [Parens in HsSyn] + !(LHsToken ")" p) | SectionL (XSectionL p) (LHsExpr p) -- operand; see Note [Sections in HsSyn] @@ -928,7 +930,9 @@ data HsCmd id -- For details on above see note [exact print annotations] in GHC.Parser.Annotation | HsCmdPar (XCmdPar id) + !(LHsToken "(" id) (LHsCmd id) -- parenthesised command + !(LHsToken ")" id) -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen' @'('@, -- 'GHC.Parser.Annotation.AnnClose' @')'@ diff --git a/compiler/Language/Haskell/Syntax/Extension.hs b/compiler/Language/Haskell/Syntax/Extension.hs index f414968a6e..2f9b9d7583 100644 --- a/compiler/Language/Haskell/Syntax/Extension.hs +++ b/compiler/Language/Haskell/Syntax/Extension.hs @@ -4,6 +4,7 @@ {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE EmptyCase #-} {-# LANGUAGE EmptyDataDeriving #-} +{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} @@ -22,6 +23,7 @@ module Language.Haskell.Syntax.Extension where import GHC.Prelude +import GHC.TypeLits (Symbol, KnownSymbol) import Data.Data hiding ( Fixity ) import Data.Kind (Type) import GHC.Utils.Outputable @@ -693,3 +695,14 @@ type family NoGhcTc (p :: Type) -- ===================================================================== -- End of Type family definitions -- ===================================================================== + + + +-- ===================================================================== +-- Token information + +type LHsToken tok p = XRec p (HsToken tok) + +data HsToken (tok :: Symbol) = HsTok + +deriving instance KnownSymbol tok => Data (HsToken tok) diff --git a/compiler/Language/Haskell/Syntax/Pat.hs b/compiler/Language/Haskell/Syntax/Pat.hs index c7829d833c..75dc7ddd00 100644 --- a/compiler/Language/Haskell/Syntax/Pat.hs +++ b/compiler/Language/Haskell/Syntax/Pat.hs @@ -9,6 +9,7 @@ {-# LANGUAGE UndecidableInstances #-} -- Wrinkle in Note [Trees That Grow] -- in module Language.Haskell.Syntax.Extension {-# LANGUAGE ViewPatterns #-} +{-# LANGUAGE DataKinds #-} {- (c) The University of Glasgow 2006 (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 @@ -74,7 +75,9 @@ data Pat p -- For details on above see note [exact print annotations] in GHC.Parser.Annotation | ParPat (XParPat p) + !(LHsToken "(" p) (LPat p) -- ^ Parenthesised pattern + !(LHsToken ")" p) -- See Note [Parens in HsSyn] in GHC.Hs.Expr -- ^ - 'GHC.Parser.Annotation.AnnKeywordId' : 'GHC.Parser.Annotation.AnnOpen' @'('@, -- 'GHC.Parser.Annotation.AnnClose' @')'@ |