diff options
author | Alan Zimmerman <alan.zimm@gmail.com> | 2015-11-11 12:03:18 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-11 12:04:22 +0100 |
commit | f0f9365fd7fe1a4c06926f390a6183449c3c6332 (patch) | |
tree | 01881be0270596fa3c36acf882a9f63138fe8f75 /compiler/hsSyn/HsBinds.hs | |
parent | ea8c116ac9eb916fdb6360a01c285bc8698dfaf9 (diff) | |
download | haskell-f0f9365fd7fe1a4c06926f390a6183449c3c6332.tar.gz |
Remove fun_infix from Funbind, as it is now in Match
One of the changes D538 introduced is to add `m_fun_id_infix` to `Match`
```lang=hs
data Match id body
= Match {
m_fun_id_infix :: (Maybe (Located id,Bool)),
-- fun_id and fun_infix for functions with multiple equations
-- only present for a RdrName. See note [fun_id in Match]
m_pats :: [LPat id], -- The patterns
m_type :: (Maybe (LHsType id)),
-- A type signature for the result of the match
-- Nothing after typechecking
m_grhss :: (GRHSs id body)
} deriving (Typeable)
```
This was done to track the individual locations and fixity of the
`fun_id` for each of the defining equations for a function when there
are more than one.
For example, the function `(&&&)` is defined with some prefix and some
infix equations below.
```lang=hs
(&&& ) [] [] = []
xs &&& [] = xs
( &&& ) [] ys = ys
```
This means that the fun_infix is now superfluous in the `FunBind`. This
has not been removed as a potentially risky change just before 7.10 RC2,
and so must be done after.
This ticket captures that task, which includes processing these fields
through the renamer and beyond.
Ticket #9988 introduced these fields into `Match` through renaming, this
ticket it to continue through type checking and then remove it from
`FunBind` completely.
The split happened so that #9988 could land in 7.10
Trac ticket : #10061
Test Plan: ./validate
Reviewers: goldfire, austin, simonpj, bgamari
Reviewed By: bgamari
Subscribers: simonpj, thomie, mpickering
Differential Revision: https://phabricator.haskell.org/D1285
GHC Trac Issues: #10061
Diffstat (limited to 'compiler/hsSyn/HsBinds.hs')
-rw-r--r-- | compiler/hsSyn/HsBinds.hs | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/compiler/hsSyn/HsBinds.hs b/compiler/hsSyn/HsBinds.hs index b1d13caf48..978d36349a 100644 --- a/compiler/hsSyn/HsBinds.hs +++ b/compiler/hsSyn/HsBinds.hs @@ -140,8 +140,6 @@ data HsBindLR idL idR fun_id :: Located idL, -- Note [fun_id in Match] in HsExpr - fun_infix :: Bool, -- ^ True => infix declaration - fun_matches :: MatchGroup idR (LHsExpr idR), -- ^ The payload fun_co_fn :: HsWrapper, -- ^ Coercion from the type of the MatchGroup to the type of @@ -488,14 +486,14 @@ ppr_monobind (PatBind { pat_lhs = pat, pat_rhs = grhss }) = pprPatBind pat grhss ppr_monobind (VarBind { var_id = var, var_rhs = rhs }) = sep [pprBndr CaseBind var, nest 2 $ equals <+> pprExpr (unLoc rhs)] -ppr_monobind (FunBind { fun_id = fun, fun_infix = inf, +ppr_monobind (FunBind { fun_id = fun, fun_co_fn = wrap, fun_matches = matches, fun_tick = ticks }) = pprTicks empty (if null ticks then empty else text "-- ticks = " <> ppr ticks) $$ ifPprDebug (pprBndr LetBind (unLoc fun)) - $$ pprFunBind (unLoc fun) inf matches + $$ pprFunBind (unLoc fun) matches $$ ifPprDebug (ppr wrap) ppr_monobind (PatSynBind psb) = ppr psb ppr_monobind (AbsBinds { abs_tvs = tyvars, abs_ev_vars = dictvars @@ -522,18 +520,18 @@ instance (OutputableBndr idL, OutputableBndr idR) => Outputable (PatSynBind idL ppr_lhs = ptext (sLit "pattern") <+> ppr_details ppr_simple syntax = syntax <+> ppr pat - (is_infix, ppr_details) = case details of - InfixPatSyn v1 v2 -> (True, hsep [ppr v1, pprInfixOcc psyn, ppr v2]) - PrefixPatSyn vs -> (False, hsep (pprPrefixOcc psyn : map ppr vs)) + ppr_details = case details of + InfixPatSyn v1 v2 -> hsep [ppr v1, pprInfixOcc psyn, ppr v2] + PrefixPatSyn vs -> hsep (pprPrefixOcc psyn : map ppr vs) RecordPatSyn vs -> - (False, pprPrefixOcc psyn - <> braces (sep (punctuate comma (map ppr vs)))) + pprPrefixOcc psyn + <> braces (sep (punctuate comma (map ppr vs))) ppr_rhs = case dir of Unidirectional -> ppr_simple (ptext (sLit "<-")) ImplicitBidirectional -> ppr_simple equals ExplicitBidirectional mg -> ppr_simple (ptext (sLit "<-")) <+> ptext (sLit "where") $$ - (nest 2 $ pprFunBind psyn is_infix mg) + (nest 2 $ pprFunBind psyn mg) pprTicks :: SDoc -> SDoc -> SDoc -- Print stuff about ticks only when -dppr-debug is on, to avoid |