MatchLit.hs 19.6 KB
Newer Older
Austin Seipp's avatar
Austin Seipp committed
1
2
3
4
{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

Simon Marlow's avatar
Simon Marlow committed
5
6

Pattern-matching literal patterns
Austin Seipp's avatar
Austin Seipp committed
7
-}
8

9
10
{-# LANGUAGE CPP, ScopedTypeVariables #-}

11
module MatchLit ( dsLit, dsOverLit, dsOverLit', hsLitKey
12
13
                , tidyLitPat, tidyNPat
                , matchLiterals, matchNPlusKPats, matchNPats
14
15
                , warnAboutIdentities, warnAboutOverflowedLiterals
                , warnAboutEmptyEnumerations
16
                ) where
17

18
19
#include "HsVersions.h"

20
21
import GhcPrelude

22
import {-# SOURCE #-} Match  ( match )
23
import {-# SOURCE #-} DsExpr ( dsExpr, dsSyntaxExpr )
24

25
import DsMonad
26
import DsUtils
27

28
import HsSyn
29

Simon Marlow's avatar
Simon Marlow committed
30
import Id
31
import CoreSyn
32
import MkCore
Simon Marlow's avatar
Simon Marlow committed
33
34
import TyCon
import DataCon
35
import TcHsSyn ( shortCutLit )
Simon Marlow's avatar
Simon Marlow committed
36
import TcType
37
38
import Name
import Type
Simon Marlow's avatar
Simon Marlow committed
39
40
41
42
import PrelNames
import TysWiredIn
import Literal
import SrcLoc
Ian Lynagh's avatar
Ian Lynagh committed
43
import Data.Ratio
44
import Outputable
45
import BasicTypes
46
import DynFlags
Simon Marlow's avatar
Simon Marlow committed
47
48
import Util
import FastString
49
import qualified GHC.LanguageExtensions as LangExt
50

51
import Control.Monad
52
53
import Data.Int
import Data.Word
54
import Data.Proxy
55

Austin Seipp's avatar
Austin Seipp committed
56
57
58
{-
************************************************************************
*                                                                      *
59
60
61
                Desugaring literals
        [used to be in DsExpr, but DsMeta needs it,
         and it's nice to avoid a loop]
Austin Seipp's avatar
Austin Seipp committed
62
63
*                                                                      *
************************************************************************
64
65
66
67
68
69
70
71
72
73
74
75
76

We give int/float literals type @Integer@ and @Rational@, respectively.
The typechecker will (presumably) have put \tr{from{Integer,Rational}s}
around them.

ToDo: put in range checks for when converting ``@i@''
(or should that be in the typechecker?)

For numeric literals, we try to detect there use at a standard type
(@Int@, @Float@, etc.) are directly put in the right constructor.
[NB: down with the @App@ conversion.]

See also below where we look for @DictApps@ for \tr{plusInt}, etc.
Austin Seipp's avatar
Austin Seipp committed
77
-}
78

79
dsLit :: HsLit GhcRn -> DsM CoreExpr
80
81
82
dsLit l = do
  dflags <- getDynFlags
  case l of
Sylvain Henry's avatar
Sylvain Henry committed
83
84
85
86
87
88
89
90
    HsStringPrim _ s -> return (Lit (LitString s))
    HsCharPrim   _ c -> return (Lit (LitChar c))
    HsIntPrim    _ i -> return (Lit (mkLitIntWrap dflags i))
    HsWordPrim   _ w -> return (Lit (mkLitWordWrap dflags w))
    HsInt64Prim  _ i -> return (Lit (mkLitInt64Wrap dflags i))
    HsWord64Prim _ w -> return (Lit (mkLitWord64Wrap dflags w))
    HsFloatPrim  _ f -> return (Lit (LitFloat (fl_value f)))
    HsDoublePrim _ d -> return (Lit (LitDouble (fl_value d)))
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    HsChar _ c       -> return (mkCharExpr c)
    HsString _ str   -> mkStringExprFS str
    HsInteger _ i _  -> mkIntegerExpr i
    HsInt _ i        -> return (mkIntExpr dflags (il_value i))
    XLit x           -> pprPanic "dsLit" (ppr x)
    HsRat _ (FL _ _ val) ty -> do
      num   <- mkIntegerExpr (numerator val)
      denom <- mkIntegerExpr (denominator val)
      return (mkCoreConApps ratio_data_con [Type integer_ty, num, denom])
      where
        (ratio_data_con, integer_ty)
            = case tcSplitTyConApp ty of
                    (tycon, [i_ty]) -> ASSERT(isIntegerTy i_ty && tycon `hasKey` ratioTyConKey)
                                       (head (tyConDataCons tycon), i_ty)
                    x -> pprPanic "dsLit" (ppr x)
106

107
dsOverLit :: HsOverLit GhcTc -> DsM CoreExpr
108
109
110
dsOverLit lit = do { dflags <- getDynFlags
                   ; warnAboutOverflowedLiterals dflags lit
                   ; dsOverLit' dflags lit }
111

112
dsOverLit' :: DynFlags -> HsOverLit GhcTc -> DsM CoreExpr
113
-- Post-typechecker, the HsExpr field of an OverLit contains
114
-- (an expression for) the literal value itself
115
116
dsOverLit' dflags (OverLit { ol_val = val, ol_ext = OverLitTc rebindable ty
                           , ol_witness = witness })
117
  | not rebindable
118
119
  , Just expr <- shortCutLit dflags val ty = dsExpr expr        -- Note [Literal short cut]
  | otherwise                              = dsExpr witness
120
dsOverLit' _ XOverLit{} = panic "dsOverLit'"
Austin Seipp's avatar
Austin Seipp committed
121
{-
122
123
Note [Literal short cut]
~~~~~~~~~~~~~~~~~~~~~~~~
124
The type checker tries to do this short-cutting as early as possible, but
Gabor Greif's avatar
typos    
Gabor Greif committed
125
because of unification etc, more information is available to the desugarer.
126
And where it's possible to generate the correct literal right away, it's
Gabor Greif's avatar
Gabor Greif committed
127
much better to do so.
128
129


Austin Seipp's avatar
Austin Seipp committed
130
131
************************************************************************
*                                                                      *
132
                 Warnings about overflowed literals
Austin Seipp's avatar
Austin Seipp committed
133
134
*                                                                      *
************************************************************************
135
136
137
138

Warn about functions like toInteger, fromIntegral, that convert
between one type and another when the to- and from- types are the
same.  Then it's probably (albeit not definitely) the identity
Austin Seipp's avatar
Austin Seipp committed
139
-}
140
141
142
143
144
145
146

warnAboutIdentities :: DynFlags -> CoreExpr -> Type -> DsM ()
warnAboutIdentities dflags (Var conv_fn) type_of_conv
  | wopt Opt_WarnIdentities dflags
  , idName conv_fn `elem` conversionNames
  , Just (arg_ty, res_ty) <- splitFunTy_maybe type_of_conv
  , arg_ty `eqType` res_ty  -- So we are converting  ty -> ty
147
148
  = warnDs (Reason Opt_WarnIdentities)
           (vcat [ text "Call of" <+> ppr conv_fn <+> dcolon <+> ppr type_of_conv
149
                 , nest 2 $ text "can probably be omitted"
150
151
152
153
154
155
156
157
158
           ])
warnAboutIdentities _ _ _ = return ()

conversionNames :: [Name]
conversionNames
  = [ toIntegerName, toRationalName
    , fromIntegralName, realToFracName ]
 -- We can't easily add fromIntegerName, fromRationalName,
 -- because they are generated by literals
159

160
warnAboutOverflowedLiterals :: DynFlags -> HsOverLit GhcTc -> DsM ()
161
162
163
warnAboutOverflowedLiterals dflags lit
 | wopt Opt_WarnOverflowedLiterals dflags
 , Just (i, tc) <- getIntegralLit lit
164
165
166
167
168
169
170
171
172
173
174
  = if      tc == intTyConName     then check i tc (Proxy :: Proxy Int)
    else if tc == int8TyConName    then check i tc (Proxy :: Proxy Int8)
    else if tc == int16TyConName   then check i tc (Proxy :: Proxy Int16)
    else if tc == int32TyConName   then check i tc (Proxy :: Proxy Int32)
    else if tc == int64TyConName   then check i tc (Proxy :: Proxy Int64)
    else if tc == wordTyConName    then check i tc (Proxy :: Proxy Word)
    else if tc == word8TyConName   then check i tc (Proxy :: Proxy Word8)
    else if tc == word16TyConName  then check i tc (Proxy :: Proxy Word16)
    else if tc == word32TyConName  then check i tc (Proxy :: Proxy Word32)
    else if tc == word64TyConName  then check i tc (Proxy :: Proxy Word64)
    else if tc == naturalTyConName then checkPositive i tc
175
176
177
    else return ()

  | otherwise = return ()
178
  where
179
180
181
182
183
184
185
186
187
    checkPositive :: Integer -> Name -> DsM ()
    checkPositive i tc
      = when (i < 0) $ do
        warnDs (Reason Opt_WarnOverflowedLiterals)
               (vcat [ text "Literal" <+> integer i
                       <+> text "is negative but" <+> ppr tc
                       <+> ptext (sLit "only supports positive numbers")
                     ])

188
    check :: forall a. (Bounded a, Integral a) => Integer -> Name -> Proxy a -> DsM ()
189
190
    check i tc _proxy
      = when (i < minB || i > maxB) $ do
191
192
        warnDs (Reason Opt_WarnOverflowedLiterals)
               (vcat [ text "Literal" <+> integer i
193
194
                       <+> text "is out of the" <+> ppr tc <+> ptext (sLit "range")
                       <+> integer minB <> text ".." <> integer maxB
195
196
197
198
199
200
                     , sug ])
      where
        minB = toInteger (minBound :: a)
        maxB = toInteger (maxBound :: a)
        sug | minB == -i   -- Note [Suggest NegativeLiterals]
            , i > 0
201
            , not (xopt LangExt.NegativeLiterals dflags)
202
            = text "If you are trying to write a large negative literal, use NegativeLiterals"
203
            | otherwise = Outputable.empty
204

Austin Seipp's avatar
Austin Seipp committed
205
{-
206
207
208
209
210
211
212
213
214
Note [Suggest NegativeLiterals]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you write
  x :: Int8
  x = -128
it'll parse as (negate 128), and overflow.  In this case, suggest NegativeLiterals.
We get an erroneous suggestion for
  x = 128
but perhaps that does not matter too much.
Austin Seipp's avatar
Austin Seipp committed
215
-}
216

217
218
warnAboutEmptyEnumerations :: DynFlags -> LHsExpr GhcTc -> Maybe (LHsExpr GhcTc)
                           -> LHsExpr GhcTc -> DsM ()
219
220
221
222
223
224
225
-- Warns about [2,3 .. 1] which returns the empty list
-- Only works for integral types, not floating point
warnAboutEmptyEnumerations dflags fromExpr mThnExpr toExpr
  | wopt Opt_WarnEmptyEnumerations dflags
  , Just (from,tc) <- getLHsIntegralLit fromExpr
  , Just mThn      <- traverse getLHsIntegralLit mThnExpr
  , Just (to,_)    <- getLHsIntegralLit toExpr
226
  , let check :: forall a. (Enum a, Num a) => Proxy a -> DsM ()
227
228
        check _proxy
          = when (null enumeration) $
229
            warnDs (Reason Opt_WarnEmptyEnumerations) (text "Enumeration is empty")
230
231
232
233
234
235
          where
            enumeration :: [a]
            enumeration = case mThn of
                            Nothing      -> [fromInteger from                    .. fromInteger to]
                            Just (thn,_) -> [fromInteger from, fromInteger thn   .. fromInteger to]

236
237
238
239
240
241
242
243
244
245
246
  = if      tc == intTyConName    then check (Proxy :: Proxy Int)
    else if tc == int8TyConName   then check (Proxy :: Proxy Int8)
    else if tc == int16TyConName  then check (Proxy :: Proxy Int16)
    else if tc == int32TyConName  then check (Proxy :: Proxy Int32)
    else if tc == int64TyConName  then check (Proxy :: Proxy Int64)
    else if tc == wordTyConName   then check (Proxy :: Proxy Word)
    else if tc == word8TyConName  then check (Proxy :: Proxy Word8)
    else if tc == word16TyConName then check (Proxy :: Proxy Word16)
    else if tc == word32TyConName then check (Proxy :: Proxy Word32)
    else if tc == word64TyConName then check (Proxy :: Proxy Word64)
    else if tc == integerTyConName then check (Proxy :: Proxy Integer)
247
248
249
250
    else return ()

  | otherwise = return ()

251
getLHsIntegralLit :: LHsExpr GhcTc -> Maybe (Integer, Name)
252
253
-- See if the expression is an Integral literal
-- Remember to look through automatically-added tick-boxes! (Trac #8384)
254
255
256
257
getLHsIntegralLit (L _ (HsPar _ e))            = getLHsIntegralLit e
getLHsIntegralLit (L _ (HsTick _ _ e))         = getLHsIntegralLit e
getLHsIntegralLit (L _ (HsBinTick _ _ _ e))    = getLHsIntegralLit e
getLHsIntegralLit (L _ (HsOverLit _ over_lit)) = getIntegralLit over_lit
258
259
getLHsIntegralLit _ = Nothing

260
getIntegralLit :: HsOverLit GhcTc -> Maybe (Integer, Name)
261
getIntegralLit (OverLit { ol_val = HsIntegral i, ol_ext = OverLitTc _ ty })
262
  | Just tc <- tyConAppTyCon_maybe ty
263
  = Just (il_value i, tyConName tc)
264
265
getIntegralLit _ = Nothing

Austin Seipp's avatar
Austin Seipp committed
266
267
268
{-
************************************************************************
*                                                                      *
269
        Tidying lit pats
Austin Seipp's avatar
Austin Seipp committed
270
271
272
*                                                                      *
************************************************************************
-}
273

274
tidyLitPat :: HsLit GhcTc -> Pat GhcTc
275
-- Result has only the following HsLits:
276
277
--      HsIntPrim, HsWordPrim, HsCharPrim, HsFloatPrim
--      HsDoublePrim, HsStringPrim, HsString
278
279
--  * HsInteger, HsRat, HsInt can't show up in LitPats
--  * We get rid of HsChar right here
280
281
tidyLitPat (HsChar src c) = unLoc (mkCharLitPat src c)
tidyLitPat (HsString src s)
282
  | lengthFS s <= 1     -- Short string literals only
283
284
  = unLoc $ foldr (\c pat -> mkPrefixConPat consDataCon
                                             [mkCharLitPat src c, pat] [charTy])
285
                  (mkNilPat charTy) (unpackFS s)
286
287
        -- The stringTy is the type of the whole pattern, not
        -- the type to instantiate (:) or [] with!
288
tidyLitPat lit = LitPat noExt lit
289

290
----------------
291
tidyNPat :: HsOverLit GhcTc -> Maybe (SyntaxExpr GhcTc) -> SyntaxExpr GhcTc
292
293
         -> Type
         -> Pat GhcTc
294
tidyNPat (OverLit (OverLitTc False ty) val _) mb_neg _eq outer_ty
295
296
297
298
299
        -- False: Take short cuts only if the literal is not using rebindable syntax
        --
        -- Once that is settled, look for cases where the type of the
        -- entire overloaded literal matches the type of the underlying literal,
        -- and in that case take the short cut
Krzysztof Gogolewski's avatar
Typos    
Krzysztof Gogolewski committed
300
        -- NB: Watch out for weird cases like Trac #3382
301
302
        --        f :: Int -> Int
        --        f "blah" = 4
303
        --     which might be ok if we have 'instance IsString Int'
304
        --
305
  | not type_change, isIntTy ty,    Just int_lit <- mb_int_lit
Alan Zimmerman's avatar
Alan Zimmerman committed
306
                 = mk_con_pat intDataCon    (HsIntPrim    NoSourceText int_lit)
307
  | not type_change, isWordTy ty,   Just int_lit <- mb_int_lit
Alan Zimmerman's avatar
Alan Zimmerman committed
308
                 = mk_con_pat wordDataCon   (HsWordPrim   NoSourceText int_lit)
309
  | not type_change, isStringTy ty, Just str_lit <- mb_str_lit
310
                 = tidyLitPat (HsString NoSourceText str_lit)
Ben Gamari's avatar
Ben Gamari committed
311
312
313
314
     -- NB: do /not/ convert Float or Double literals to F# 3.8 or D# 5.3
     -- If we do convert to the constructor form, we'll generate a case
     -- expression on a Float# or Double# and that's not allowed in Core; see
     -- Trac #9238 and Note [Rules for floating-point comparisons] in PrelRules
315
  where
316
317
318
319
320
321
    -- Sometimes (like in test case
    -- overloadedlists/should_run/overloadedlistsrun04), the SyntaxExprs include
    -- type-changing wrappers (for example, from Id Int to Int, for the identity
    -- type family Id). In these cases, we can't do the short-cut.
    type_change = not (outer_ty `eqType` ty)

322
    mk_con_pat :: DataCon -> HsLit GhcTc -> Pat GhcTc
323
324
    mk_con_pat con lit
      = unLoc (mkPrefixConPat con [noLoc $ LitPat noExt lit] [])
325

326
327
    mb_int_lit :: Maybe Integer
    mb_int_lit = case (mb_neg, val) of
328
329
                   (Nothing, HsIntegral i) -> Just (il_value i)
                   (Just _,  HsIntegral i) -> Just (-(il_value i))
330
331
                   _ -> Nothing

332
333
    mb_str_lit :: Maybe FastString
    mb_str_lit = case (mb_neg, val) of
334
                   (Nothing, HsIsString _ s) -> Just s
335
                   _ -> Nothing
336

337
tidyNPat over_lit mb_neg eq outer_ty
338
  = NPat outer_ty (noLoc over_lit) mb_neg eq
339

Austin Seipp's avatar
Austin Seipp committed
340
341
342
{-
************************************************************************
*                                                                      *
343
                Pattern matching on LitPat
Austin Seipp's avatar
Austin Seipp committed
344
345
346
*                                                                      *
************************************************************************
-}
347

348
matchLiterals :: [Id]
349
350
351
              -> Type                   -- Type of the whole case expression
              -> [[EquationInfo]]       -- All PgLits
              -> DsM MatchResult
352

353
matchLiterals (var:vars) ty sub_groups
354
  = ASSERT( notNull sub_groups && all notNull sub_groups )
355
356
357
358
359
360
361
362
363
364
365
366
367
    do  {       -- Deal with each group
        ; alts <- mapM match_group sub_groups

                -- Combine results.  For everything except String
                -- we can use a case expression; for String we need
                -- a chain of if-then-else
        ; if isStringTy (idType var) then
            do  { eq_str <- dsLookupGlobalId eqStringName
                ; mrs <- mapM (wrap_str_guard eq_str) alts
                ; return (foldr1 combineMatchResults mrs) }
          else
            return (mkCoPrimCaseMatchResult var ty alts)
        }
368
  where
369
370
    match_group :: [EquationInfo] -> DsM (Literal, MatchResult)
    match_group eqns
371
        = do dflags <- getDynFlags
372
             let LitPat _ hs_lit = firstPat (head eqns)
373
374
             match_result <- match vars ty (shiftEqns eqns)
             return (hsLitKey dflags hs_lit, match_result)
375

376
    wrap_str_guard :: Id -> (Literal,MatchResult) -> DsM MatchResult
377
        -- Equality check for string literals
Sylvain Henry's avatar
Sylvain Henry committed
378
    wrap_str_guard eq_str (LitString s, mr)
379
        = do { -- We now have to convert back to FastString. Perhaps there
Sylvain Henry's avatar
Sylvain Henry committed
380
               -- should be separate LitBytes and LitString constructors?
381
               let s'  = mkFastStringByteString s
382
383
384
             ; lit    <- mkStringExprFS s'
             ; let pred = mkApps (Var eq_str) [Var var, lit]
             ; return (mkGuardedMatchResult pred mr) }
Ian Lynagh's avatar
Ian Lynagh committed
385
386
387
    wrap_str_guard _ (l, _) = pprPanic "matchLiterals/wrap_str_guard" (ppr l)

matchLiterals [] _ _ = panic "matchLiterals []"
388

389
---------------------------
390
hsLitKey :: DynFlags -> HsLit GhcTc -> Literal
391
-- Get the Core literal corresponding to a HsLit.
392
393
-- It only works for primitive types and strings;
-- others have been removed by tidy
Sylvain Henry's avatar
Sylvain Henry committed
394
-- For HsString, it produces a LitString, which really represents an _unboxed_
395
396
397
398
399
-- string literal; and we deal with it in matchLiterals above. Otherwise, it
-- produces a primitive Literal of type matching the original HsLit.
-- In the case of the fixed-width numeric types, we need to wrap here
-- because Literal has an invariant that the literal is in range, while
-- HsLit does not.
Sylvain Henry's avatar
Sylvain Henry committed
400
401
402
403
404
405
406
407
hsLitKey dflags (HsIntPrim    _ i) = mkLitIntWrap  dflags i
hsLitKey dflags (HsWordPrim   _ w) = mkLitWordWrap dflags w
hsLitKey dflags (HsInt64Prim  _ i) = mkLitInt64Wrap  dflags i
hsLitKey dflags (HsWord64Prim _ w) = mkLitWord64Wrap dflags w
hsLitKey _      (HsCharPrim   _ c) = mkLitChar            c
hsLitKey _      (HsFloatPrim  _ f) = mkLitFloat           (fl_value f)
hsLitKey _      (HsDoublePrim _ d) = mkLitDouble          (fl_value d)
hsLitKey _      (HsString _ s)     = LitString (fastStringToByteString s)
408
hsLitKey _      l                  = pprPanic "hsLitKey" (ppr l)
409

Austin Seipp's avatar
Austin Seipp committed
410
411
412
{-
************************************************************************
*                                                                      *
413
                Pattern matching on NPat
Austin Seipp's avatar
Austin Seipp committed
414
415
416
*                                                                      *
************************************************************************
-}
417

418
matchNPats :: [Id] -> Type -> [EquationInfo] -> DsM MatchResult
419
matchNPats (var:vars) ty (eqn1:eqns)    -- All for the same literal
420
  = do  { let NPat _ (L _ lit) mb_neg eq_chk = firstPat eqn1
421
422
        ; lit_expr <- dsOverLit lit
        ; neg_lit <- case mb_neg of
423
424
425
                            Nothing  -> return lit_expr
                            Just neg -> dsSyntaxExpr neg [lit_expr]
        ; pred_expr <- dsSyntaxExpr eq_chk [Var var, neg_lit]
426
427
        ; match_result <- match vars ty (shiftEqns (eqn1:eqns))
        ; return (mkGuardedMatchResult pred_expr match_result) }
428
matchNPats vars _ eqns = pprPanic "matchOneNPat" (ppr (vars, eqns))
429

Austin Seipp's avatar
Austin Seipp committed
430
431
432
{-
************************************************************************
*                                                                      *
433
                Pattern matching on n+k patterns
Austin Seipp's avatar
Austin Seipp committed
434
435
*                                                                      *
************************************************************************
436

437
438
439
440
For an n+k pattern, we use the various magic expressions we've been given.
We generate:
\begin{verbatim}
    if ge var lit then
441
442
        let n = sub var lit
        in  <expr-for-a-successful-match>
443
    else
444
        <try-next-pattern-or-whatever>
445
\end{verbatim}
Austin Seipp's avatar
Austin Seipp committed
446
-}
447

448
matchNPlusKPats :: [Id] -> Type -> [EquationInfo] -> DsM MatchResult
Ian Lynagh's avatar
Ian Lynagh committed
449
450
-- All NPlusKPats, for the *same* literal k
matchNPlusKPats (var:vars) ty (eqn1:eqns)
451
  = do  { let NPlusKPat _ (L _ n1) (L _ lit1) lit2 ge minus = firstPat eqn1
452
453
454
455
456
        ; lit1_expr   <- dsOverLit lit1
        ; lit2_expr   <- dsOverLit lit2
        ; pred_expr   <- dsSyntaxExpr ge    [Var var, lit1_expr]
        ; minusk_expr <- dsSyntaxExpr minus [Var var, lit2_expr]
        ; let (wraps, eqns') = mapAndUnzip (shift n1) (eqn1:eqns)
457
458
459
460
461
        ; match_result <- match vars ty eqns'
        ; return  (mkGuardedMatchResult pred_expr               $
                   mkCoLetMatchResult (NonRec n1 minusk_expr)   $
                   adjustMatchResult (foldr1 (.) wraps)         $
                   match_result) }
462
  where
463
    shift n1 eqn@(EqnInfo { eqn_pats = NPlusKPat _ (L _ n) _ _ _ _ : pats })
464
465
        = (wrapBind n n1, eqn { eqn_pats = pats })
        -- The wrapBind is a no-op for the first equation
Ian Lynagh's avatar
Ian Lynagh committed
466
467
468
    shift _ e = pprPanic "matchNPlusKPats/shift" (ppr e)

matchNPlusKPats vars _ eqns = pprPanic "matchNPlusKPats" (ppr (vars, eqns))