diff options
author | Simon Peyton Jones <simonpj@microsoft.com> | 2016-03-30 17:14:11 +0100 |
---|---|---|
committer | Simon Peyton Jones <simonpj@microsoft.com> | 2016-03-31 08:04:04 +0100 |
commit | bdd90426a7f88d57bedf15411fa00f62aeb22172 (patch) | |
tree | 378a99bb29281b420a836cb13cfb78e65268cf57 /compiler/hsSyn/HsExpr.hs | |
parent | 2e5e8223e2fd0fe7f6082a15627dfd54e3560b06 (diff) | |
download | haskell-bdd90426a7f88d57bedf15411fa00f62aeb22172.tar.gz |
Refactor in TcMatches
* Move the several calls of tauifyMultipleMatches into tcMatches,
so that it can be called only once, and the invariants are
clearer
* I discovered in doing this that HsLamCase had a redundant and
tiresome argument, so I removed it. That in turn allowed some
modest but nice code simplification
Diffstat (limited to 'compiler/hsSyn/HsExpr.hs')
-rw-r--r-- | compiler/hsSyn/HsExpr.hs | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/hsSyn/HsExpr.hs b/compiler/hsSyn/HsExpr.hs index a18fbd4765..05f1ac8ce1 100644 --- a/compiler/hsSyn/HsExpr.hs +++ b/compiler/hsSyn/HsExpr.hs @@ -194,7 +194,7 @@ data HsExpr id -- For details on above see note [Api annotations] in ApiAnnotation - | HsLamCase (PostTc id Type) (MatchGroup id (LHsExpr id)) -- ^ Lambda-case + | HsLamCase (MatchGroup id (LHsExpr id)) -- ^ Lambda-case -- -- - 'ApiAnnotation.AnnKeywordId' : 'ApiAnnotation.AnnLam', -- 'ApiAnnotation.AnnCase','ApiAnnotation.AnnOpen', @@ -751,7 +751,7 @@ ppr_expr (ExplicitTuple exprs boxity) ppr_expr (HsLam matches) = pprMatches (LambdaExpr :: HsMatchContext id) matches -ppr_expr (HsLamCase _ matches) +ppr_expr (HsLamCase matches) = sep [ sep [text "\\case {"], nest 2 (pprMatches (CaseAlt :: HsMatchContext id) matches <+> char '}') ] @@ -1260,12 +1260,14 @@ isInfixMatch match = case m_fixity match of isEmptyMatchGroup :: MatchGroup id body -> Bool isEmptyMatchGroup (MG { mg_alts = ms }) = null $ unLoc ms --- | Is there only one RHS in this group? -isSingletonMatchGroup :: MatchGroup id body -> Bool -isSingletonMatchGroup (MG { mg_alts = L _ [match] }) - | L _ (Match { m_grhss = GRHSs { grhssGRHSs = [_] } }) <- match +-- | Is there only one RHS in this list of matches? +isSingletonMatchGroup :: [LMatch id body] -> Bool +isSingletonMatchGroup matches + | [L _ match] <- matches + , Match { m_grhss = GRHSs { grhssGRHSs = [_] } } <- match = True -isSingletonMatchGroup _ = False + | otherwise + = False matchGroupArity :: MatchGroup id body -> Arity -- Precondition: MatchGroup is non-empty |