diff options
author | Ryan Scott <ryan.gl.scott@gmail.com> | 2019-03-19 17:47:55 -0400 |
---|---|---|
committer | Ben Gamari <ben@well-typed.com> | 2019-07-09 11:52:45 -0400 |
commit | 6a03d77b9a9915e4b37fe1ea6688c135e7b00654 (patch) | |
tree | 4154abaa768adbfadc4eb17db620c3ed08b82c5f /compiler/hsSyn/HsPat.hs | |
parent | 5af815f2e43e9f1b5ca9ec0803f9fccabb49e2fe (diff) | |
download | haskell-6a03d77b9a9915e4b37fe1ea6688c135e7b00654.tar.gz |
Use an empty data type in TTG extension constructors (#15247)
To avoid having to `panic` any time a TTG extension constructor is
consumed, this MR introduces an uninhabited 'NoExtCon' type and uses
that in every extension constructor's type family instance where it
is appropriate. This also introduces a 'noExtCon' function which
eliminates a 'NoExtCon', much like 'Data.Void.absurd' eliminates
a 'Void'.
I also renamed the existing `NoExt` type to `NoExtField` to better
distinguish it from `NoExtCon`. Unsurprisingly, there is a lot of
code churn resulting from this.
Bumps the Haddock submodule. Fixes #15247.
Diffstat (limited to 'compiler/hsSyn/HsPat.hs')
-rw-r--r-- | compiler/hsSyn/HsPat.hs | 54 |
1 files changed, 27 insertions, 27 deletions
diff --git a/compiler/hsSyn/HsPat.hs b/compiler/hsSyn/HsPat.hs index bce65ba25a..9f8d2a5ed4 100644 --- a/compiler/hsSyn/HsPat.hs +++ b/compiler/hsSyn/HsPat.hs @@ -281,51 +281,51 @@ data ListPatTc Type -- The type of the elements (Maybe (Type, SyntaxExpr GhcTc)) -- For rebindable syntax -type instance XWildPat GhcPs = NoExt -type instance XWildPat GhcRn = NoExt +type instance XWildPat GhcPs = NoExtField +type instance XWildPat GhcRn = NoExtField type instance XWildPat GhcTc = Type -type instance XVarPat (GhcPass _) = NoExt -type instance XLazyPat (GhcPass _) = NoExt -type instance XAsPat (GhcPass _) = NoExt -type instance XParPat (GhcPass _) = NoExt -type instance XBangPat (GhcPass _) = NoExt +type instance XVarPat (GhcPass _) = NoExtField +type instance XLazyPat (GhcPass _) = NoExtField +type instance XAsPat (GhcPass _) = NoExtField +type instance XParPat (GhcPass _) = NoExtField +type instance XBangPat (GhcPass _) = NoExtField -- Note: XListPat cannot be extended when using GHC 8.0.2 as the bootstrap -- compiler, as it triggers https://gitlab.haskell.org/ghc/ghc/issues/14396 for -- `SyntaxExpr` -type instance XListPat GhcPs = NoExt +type instance XListPat GhcPs = NoExtField type instance XListPat GhcRn = Maybe (SyntaxExpr GhcRn) type instance XListPat GhcTc = ListPatTc -type instance XTuplePat GhcPs = NoExt -type instance XTuplePat GhcRn = NoExt +type instance XTuplePat GhcPs = NoExtField +type instance XTuplePat GhcRn = NoExtField type instance XTuplePat GhcTc = [Type] -type instance XSumPat GhcPs = NoExt -type instance XSumPat GhcRn = NoExt +type instance XSumPat GhcPs = NoExtField +type instance XSumPat GhcRn = NoExtField type instance XSumPat GhcTc = [Type] -type instance XViewPat GhcPs = NoExt -type instance XViewPat GhcRn = NoExt +type instance XViewPat GhcPs = NoExtField +type instance XViewPat GhcRn = NoExtField type instance XViewPat GhcTc = Type -type instance XSplicePat (GhcPass _) = NoExt -type instance XLitPat (GhcPass _) = NoExt +type instance XSplicePat (GhcPass _) = NoExtField +type instance XLitPat (GhcPass _) = NoExtField -type instance XNPat GhcPs = NoExt -type instance XNPat GhcRn = NoExt +type instance XNPat GhcPs = NoExtField +type instance XNPat GhcRn = NoExtField type instance XNPat GhcTc = Type -type instance XNPlusKPat GhcPs = NoExt -type instance XNPlusKPat GhcRn = NoExt +type instance XNPlusKPat GhcPs = NoExtField +type instance XNPlusKPat GhcRn = NoExtField type instance XNPlusKPat GhcTc = Type -type instance XSigPat GhcPs = NoExt -type instance XSigPat GhcRn = NoExt +type instance XSigPat GhcPs = NoExtField +type instance XSigPat GhcRn = NoExtField type instance XSigPat GhcTc = Type -type instance XCoPat (GhcPass _) = NoExt +type instance XCoPat (GhcPass _) = NoExtField type instance XXPat (GhcPass p) = Located (Pat (GhcPass p)) @@ -460,11 +460,11 @@ data HsRecField' id arg = HsRecField { -- -- The parsed HsRecUpdField corresponding to the record update will have: -- --- hsRecFieldLbl = Unambiguous "x" NoExt :: AmbiguousFieldOcc RdrName +-- hsRecFieldLbl = Unambiguous "x" noExtField :: AmbiguousFieldOcc RdrName -- -- After the renamer, this will become: -- --- hsRecFieldLbl = Ambiguous "x" NoExt :: AmbiguousFieldOcc Name +-- hsRecFieldLbl = Ambiguous "x" noExtField :: AmbiguousFieldOcc Name -- -- (note that the Unambiguous constructor is not type-correct here). -- The typechecker will determine the particular selector: @@ -630,7 +630,7 @@ mkNilPat ty = mkPrefixConPat nilDataCon [] [ty] mkCharLitPat :: SourceText -> Char -> OutPat (GhcPass p) mkCharLitPat src c = mkPrefixConPat charDataCon - [noLoc $ LitPat NoExt (HsCharPrim src c)] [] + [noLoc $ LitPat noExtField (HsCharPrim src c)] [] {- ************************************************************************ @@ -811,7 +811,7 @@ conPatNeedsParens p = go -- if so, surrounds @pat@ with a 'ParPat'. Otherwise, it simply returns @pat@. parenthesizePat :: PprPrec -> LPat (GhcPass p) -> LPat (GhcPass p) parenthesizePat p lpat@(dL->L loc pat) - | patNeedsParens p pat = cL loc (ParPat NoExt lpat) + | patNeedsParens p pat = cL loc (ParPat noExtField lpat) | otherwise = lpat {- |