diff options
Diffstat (limited to 'libraries/template-haskell/Language')
3 files changed, 6 insertions, 4 deletions
diff --git a/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs b/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs index 11e53ca701..0154c59d22 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Lib/Internal.hs @@ -23,6 +23,7 @@ import qualified Language.Haskell.TH.Syntax as TH import Control.Applicative(liftA, liftA2) import qualified Data.Kind as Kind (Type) import Data.Word( Word8 ) +import Data.List.NonEmpty ( NonEmpty(..) ) import GHC.Exts (TYPE) import Prelude @@ -371,8 +372,8 @@ getFieldE e f = do e' <- e pure (GetFieldE e' f) -projectionE :: Quote m => [String] -> m Exp -projectionE xs = pure (ProjectionE xs) +projectionE :: Quote m => NonEmpty String -> m Exp +projectionE (x :| xs) = pure (ProjectionE x xs) -- ** 'arithSeqE' Shortcuts fromE :: Quote m => m Exp -> m Exp diff --git a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs index 7ed842ca94..d7c4ee1aca 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Ppr.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Ppr.hs @@ -224,7 +224,7 @@ pprExp _ (UnboundVarE v) = pprName' Applied v pprExp _ (LabelE s) = text "#" <> text s pprExp _ (ImplicitParamVarE n) = text ('?' : n) pprExp _ (GetFieldE e f) = pprExp appPrec e <> text ('.': f) -pprExp _ (ProjectionE xs) = parens $ hcat $ map ((char '.'<>) . text) xs +pprExp _ (ProjectionE x xs) = parens $ hcat $ map ((char '.'<>) . text) (x:xs) pprFields :: [(Name,Exp)] -> Doc pprFields = sep . punctuate comma . map (\(s,e) -> pprName' Applied s <+> equals <+> ppr e) diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs index c219467337..76b9b954a5 100644 --- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs +++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs @@ -2234,7 +2234,8 @@ data Exp | LabelE String -- ^ @{ #x }@ ( Overloaded label ) | ImplicitParamVarE String -- ^ @{ ?x }@ ( Implicit parameter ) | GetFieldE Exp String -- ^ @{ exp.field }@ ( Overloaded Record Dot ) - | ProjectionE [String] -- ^ @(.x)@ or @(.x.y)@ (Record projections) + | ProjectionE String [String] -- ^ @(.x)@ or @(.x.y)@ or @(.x.y.z)@ etc. (Record projections) + -- There has to be at least one projection in the expression deriving( Show, Eq, Ord, Data, Generic ) type FieldExp = (Name,Exp) |