summaryrefslogtreecommitdiff
path: root/compiler/GHC
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC')
-rw-r--r--compiler/GHC/Hs/Pat.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/compiler/GHC/Hs/Pat.hs b/compiler/GHC/Hs/Pat.hs
index 945c2c195f..9812fe2c44 100644
--- a/compiler/GHC/Hs/Pat.hs
+++ b/compiler/GHC/Hs/Pat.hs
@@ -31,6 +31,7 @@ module GHC.Hs.Pat (
mkPrefixConPat, mkCharLitPat, mkNilPat,
+ isSimplePat,
looksLazyPatBind,
isBangedLPat,
patNeedsParens, parenthesizePat,
@@ -274,6 +275,7 @@ data Pat p
| XPat
(XXPat p)
+
-- ---------------------------------------------------------------------
data ListPatTc
@@ -730,6 +732,23 @@ isIrrefutableHsPat
go (XPat {}) = False
+-- | Is the pattern any of combination of:
+--
+-- - (pat)
+-- - pat :: Type
+-- - ~pat
+-- - !pat
+-- - x (variable)
+isSimplePat :: LPat (GhcPass x) -> Maybe (IdP (GhcPass x))
+isSimplePat p = case unLoc p of
+ ParPat _ x -> isSimplePat x
+ SigPat _ x _ -> isSimplePat x
+ LazyPat _ x -> isSimplePat x
+ BangPat _ x -> isSimplePat x
+ VarPat _ x -> Just (unLoc x)
+ _ -> Nothing
+
+
{- Note [Unboxed sum patterns aren't irrefutable]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unlike unboxed tuples, unboxed sums are *not* irrefutable when used as