2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
4 \section[RnBinds]{Renaming and dependency analysis of bindings}
6 This module does renaming and dependency analysis on value bindings in
7 the abstract syntax. It does {\em not} do cycle-checks on class or
8 type-synonym declarations; those cannot be done at this stage because
9 they may be affected by renaming (which isn't fully worked out yet).
14 rnLocalBindsAndThen, rnValBindsAndThen, rnValBinds, trimWith,
15 rnMethodBinds, renameSigs,
19 #include "HsVersions.h"
21 import {-# SOURCE #-} RnExpr( rnLExpr, rnStmts )
27 import RnTypes ( rnHsSigType, rnLHsType, rnHsTypeFVs,
28 rnLPat, rnPatsAndThen, patSigErr, checkPrecMatch )
29 import RnEnv ( bindLocatedLocalsRn, lookupLocatedBndrRn,
30 lookupLocatedInstDeclBndr, newIPNameRn,
31 lookupLocatedSigOccRn, bindPatSigTyVars, bindPatSigTyVarsFV,
32 bindLocalFixities, bindSigTyVarsFV,
33 warnUnusedLocalBinds, mapFvRn, extendTyVarEnvFVRn,
35 import DynFlags ( DynFlag(..) )
36 import Name ( Name, nameOccName, nameSrcLoc )
39 import PrelNames ( isUnboundName )
40 import RdrName ( RdrName, rdrNameOcc )
41 import SrcLoc ( mkSrcSpan, Located(..), unLoc )
42 import ListSetOps ( findDupsEq )
43 import BasicTypes ( RecFlag(..) )
44 import Digraph ( SCC(..), stronglyConnComp )
47 import Maybes ( orElse, fromJust, isJust )
48 import Util ( filterOut )
49 import Monad ( foldM )
52 -- ToDo: Put the annotations into the monad, so that they arrive in the proper
53 -- place and can be used when complaining.
55 The code tree received by the function @rnBinds@ contains definitions
56 in where-clauses which are all apparently mutually recursive, but which may
57 not really depend upon each other. For example, in the top level program
62 the definitions of @a@ and @y@ do not depend on each other at all.
63 Unfortunately, the typechecker cannot always check such definitions.
64 \footnote{Mycroft, A. 1984. Polymorphic type schemes and recursive
65 definitions. In Proceedings of the International Symposium on Programming,
66 Toulouse, pp. 217-39. LNCS 167. Springer Verlag.}
67 However, the typechecker usually can check definitions in which only the
68 strongly connected components have been collected into recursive bindings.
69 This is precisely what the function @rnBinds@ does.
71 ToDo: deal with case where a single monobinds binds the same variable
74 The vertag tag is a unique @Int@; the tags only need to be unique
75 within one @MonoBinds@, so that unique-Int plumbing is done explicitly
76 (heavy monad machinery not needed).
79 %************************************************************************
81 %* naming conventions *
83 %************************************************************************
85 \subsection[name-conventions]{Name conventions}
87 The basic algorithm involves walking over the tree and returning a tuple
88 containing the new tree plus its free variables. Some functions, such
89 as those walking polymorphic bindings (HsBinds) and qualifier lists in
90 list comprehensions (@Quals@), return the variables bound in local
91 environments. These are then used to calculate the free variables of the
92 expression evaluated in these environments.
94 Conventions for variable names are as follows:
97 new code is given a prime to distinguish it from the old.
100 a set of variables defined in @Exp@ is written @dvExp@
103 a set of variables free in @Exp@ is written @fvExp@
106 %************************************************************************
108 %* analysing polymorphic bindings (HsBindGroup, HsBind)
110 %************************************************************************
112 \subsubsection[dep-HsBinds]{Polymorphic bindings}
114 Non-recursive expressions are reconstructed without any changes at top
115 level, although their component expressions may have to be altered.
116 However, non-recursive expressions are currently not expected as
117 \Haskell{} programs, and this code should not be executed.
119 Monomorphic bindings contain information that is returned in a tuple
120 (a @FlatMonoBinds@) containing:
124 a unique @Int@ that serves as the ``vertex tag'' for this binding.
127 the name of a function or the names in a pattern. These are a set
128 referred to as @dvLhs@, the defined variables of the left hand side.
131 the free variables of the body. These are referred to as @fvBody@.
134 the definition's actual code. This is referred to as just @code@.
137 The function @nonRecDvFv@ returns two sets of variables. The first is
138 the set of variables defined in the set of monomorphic bindings, while the
139 second is the set of free variables in those bindings.
141 The set of variables defined in a non-recursive binding is just the
142 union of all of them, as @union@ removes duplicates. However, the
143 free variables in each successive set of cumulative bindings is the
144 union of those in the previous set plus those of the newest binding after
145 the defined variables of the previous set have been removed.
147 @rnMethodBinds@ deals only with the declarations in class and
148 instance declarations. It expects only to see @FunMonoBind@s, and
149 it expects the global environment to contain bindings for the binders
150 (which are all class operations).
152 %************************************************************************
154 \subsubsection{ Top-level bindings}
156 %************************************************************************
158 @rnTopMonoBinds@ assumes that the environment already
159 contains bindings for the binders of this particular binding.
162 rnTopBinds :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses)
164 -- The binders of the binding are in scope already;
165 -- the top level scope resolution does that
168 = do { is_boot <- tcIsHsBoot
169 ; if is_boot then rnTopBindsBoot binds
170 else rnTopBindsSrc binds }
172 rnTopBindsBoot :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses)
173 -- A hs-boot file has no bindings.
174 -- Return a single HsBindGroup with empty binds and renamed signatures
175 rnTopBindsBoot (ValBindsIn mbinds sigs)
176 = do { checkErr (isEmptyLHsBinds mbinds) (bindsInHsBootFile mbinds)
177 ; sigs' <- renameSigs okHsBootSig sigs
178 ; return (ValBindsOut [] sigs', usesOnly (hsSigsFVs sigs')) }
180 rnTopBindsSrc :: HsValBinds RdrName -> RnM (HsValBinds Name, DefUses)
181 rnTopBindsSrc binds@(ValBindsIn mbinds _)
182 = bindPatSigTyVars (collectSigTysFromHsBinds mbinds) $ \ _ ->
183 -- Hmm; by analogy with Ids, this doesn't look right
184 -- Top-level bound type vars should really scope over
185 -- everything, but we only scope them over the other bindings
187 do { (binds', dus) <- rnValBinds noTrim binds
189 -- Warn about missing signatures,
190 ; let { ValBindsOut _ sigs' = binds'
191 ; ty_sig_vars = mkNameSet [ unLoc n | L _ (TypeSig n _) <- sigs']
192 ; un_sigd_bndrs = duDefs dus `minusNameSet` ty_sig_vars }
194 ; warn_missing_sigs <- doptM Opt_WarnMissingSigs
195 ; ifM (warn_missing_sigs)
196 (mappM_ missingSigWarn (nameSetToList un_sigd_bndrs))
198 ; return (binds', dus)
204 %*********************************************************
208 %*********************************************************
212 :: HsLocalBinds RdrName
213 -> (HsLocalBinds Name -> RnM (result, FreeVars))
214 -> RnM (result, FreeVars)
215 -- This version (a) assumes that the binding vars are not already in scope
216 -- (b) removes the binders from the free vars of the thing inside
217 -- The parser doesn't produce ThenBinds
218 rnLocalBindsAndThen EmptyLocalBinds thing_inside
219 = thing_inside EmptyLocalBinds
221 rnLocalBindsAndThen (HsValBinds val_binds) thing_inside
222 = rnValBindsAndThen val_binds $ \ val_binds' ->
223 thing_inside (HsValBinds val_binds')
225 rnLocalBindsAndThen (HsIPBinds binds) thing_inside
226 = rnIPBinds binds `thenM` \ (binds',fv_binds) ->
227 thing_inside (HsIPBinds binds') `thenM` \ (thing, fvs_thing) ->
228 returnM (thing, fvs_thing `plusFV` fv_binds)
231 rnIPBinds (IPBinds ip_binds _no_dict_binds)
232 = do { (ip_binds', fvs_s) <- mapAndUnzipM (wrapLocFstM rnIPBind) ip_binds
233 ; return (IPBinds ip_binds' emptyLHsBinds, plusFVs fvs_s) }
235 rnIPBind (IPBind n expr)
236 = newIPNameRn n `thenM` \ name ->
237 rnLExpr expr `thenM` \ (expr',fvExpr) ->
238 return (IPBind name expr', fvExpr)
242 %************************************************************************
246 %************************************************************************
249 rnValBindsAndThen :: HsValBinds RdrName
250 -> (HsValBinds Name -> RnM (result, FreeVars))
251 -> RnM (result, FreeVars)
253 rnValBindsAndThen binds@(ValBindsIn mbinds sigs) thing_inside
254 = -- Extract all the binders in this group, and extend the
255 -- current scope, inventing new names for the new binders
256 -- This also checks that the names form a set
257 bindLocatedLocalsRn doc mbinders_w_srclocs $ \ bndrs ->
258 bindPatSigTyVarsFV (collectSigTysFromHsBinds mbinds) $
260 -- Then install local fixity declarations
261 -- Notice that they scope over thing_inside too
262 bindLocalFixities [sig | L _ (FixSig sig) <- sigs ] $
265 rnValBinds (trimWith bndrs) binds `thenM` \ (binds, bind_dus) ->
267 -- Now do the "thing inside"
268 thing_inside binds `thenM` \ (result,result_fvs) ->
270 -- Final error checking
272 all_uses = duUses bind_dus `plusFV` result_fvs
273 -- duUses: It's important to return all the uses, not the 'real uses'
274 -- used for warning about unused bindings. Otherwise consider:
276 -- y = let p = x in 'x' -- NB: p not used
277 -- If we don't "see" the dependency of 'y' on 'x', we may put the
278 -- bindings in the wrong order, and the type checker will complain
279 -- that x isn't in scope
281 unused_bndrs = [ b | b <- bndrs, not (b `elemNameSet` all_uses)]
283 warnUnusedLocalBinds unused_bndrs `thenM_`
285 returnM (result, delListFromNameSet all_uses bndrs)
287 mbinders_w_srclocs = collectHsBindLocatedBinders mbinds
288 doc = text "In the binding group for:"
289 <+> pprWithCommas ppr (map unLoc mbinders_w_srclocs)
291 ---------------------
292 rnValBinds :: (FreeVars -> FreeVars)
293 -> HsValBinds RdrName
294 -> RnM (HsValBinds Name, DefUses)
295 -- Assumes the binders of the binding are in scope already
297 rnValBinds trim (ValBindsIn mbinds sigs)
298 = do { sigs' <- rename_sigs sigs
300 ; binds_w_dus <- mapBagM (rnBind (mkSigTvFn sigs') trim) mbinds
302 ; let (binds', bind_dus) = depAnalBinds binds_w_dus
304 -- We do the check-sigs after renaming the bindings,
305 -- so that we have convenient access to the binders
306 ; check_sigs (okBindSig (duDefs bind_dus)) sigs'
308 ; return (ValBindsOut binds' sigs',
309 usesOnly (hsSigsFVs sigs') `plusDU` bind_dus) }
312 ---------------------
313 depAnalBinds :: Bag (LHsBind Name, [Name], Uses)
314 -> ([(RecFlag, LHsBinds Name)], DefUses)
315 -- Dependency analysis; this is important so that
316 -- unused-binding reporting is accurate
317 depAnalBinds binds_w_dus
318 = (map get_binds sccs, map get_du sccs)
320 sccs = stronglyConnComp edges
322 keyd_nodes = bagToList binds_w_dus `zip` [0::Int ..]
324 edges = [ (node, key, [fromJust mb_key | n <- nameSetToList uses,
325 let mb_key = lookupNameEnv key_map n,
327 | (node@(_,_,uses), key) <- keyd_nodes ]
329 key_map :: NameEnv Int -- Which binding it comes from
330 key_map = mkNameEnv [(bndr, key) | ((_, bndrs, _), key) <- keyd_nodes
333 get_binds (AcyclicSCC (bind, _, _)) = (NonRecursive, unitBag bind)
334 get_binds (CyclicSCC binds_w_dus) = (Recursive, listToBag [b | (b,d,u) <- binds_w_dus])
336 get_du (AcyclicSCC (_, bndrs, uses)) = (Just (mkNameSet bndrs), uses)
337 get_du (CyclicSCC binds_w_dus) = (Just defs, uses)
339 defs = mkNameSet [b | (_,bs,_) <- binds_w_dus, b <- bs]
340 uses = unionManyNameSets [u | (_,_,u) <- binds_w_dus]
343 ---------------------
344 -- Bind the top-level forall'd type variables in the sigs.
347 -- The 'a' scopes over the rhs
349 -- NB: there'll usually be just one (for a function binding)
350 -- but if there are many, one may shadow the rest; too bad!
351 -- e.g x :: [a] -> [a]
354 -- In e, 'a' will be in scope, and it'll be the one from 'y'!
356 mkSigTvFn :: [LSig Name] -> (Name -> [Name])
357 -- Return a lookup function that maps an Id Name to the names
358 -- of the type variables that should scope over its body..
360 = \n -> lookupNameEnv env n `orElse` []
362 env :: NameEnv [Name]
363 env = mkNameEnv [ (name, map hsLTyVarName ltvs)
364 | L _ (TypeSig (L _ name)
365 (L _ (HsForAllTy Explicit ltvs _ _))) <- sigs]
366 -- Note the pattern-match on "Explicit"; we only bind
367 -- type variables from signatures with an explicit top-level for-all
369 -- The trimming function trims the free vars we attach to a
370 -- binding so that it stays reasonably small
371 noTrim :: FreeVars -> FreeVars
372 noTrim fvs = fvs -- Used at top level
374 trimWith :: [Name] -> FreeVars -> FreeVars
375 -- Nested bindings; trim by intersection with the names bound here
376 trimWith bndrs = intersectNameSet (mkNameSet bndrs)
378 ---------------------
379 rnBind :: (Name -> [Name]) -- Signature tyvar function
380 -> (FreeVars -> FreeVars) -- Trimming function for rhs free vars
382 -> RnM (LHsBind Name, [Name], Uses)
383 rnBind sig_fn trim (L loc (PatBind pat grhss ty _))
385 do { (pat', pat_fvs) <- rnLPat pat
387 ; let bndrs = collectPatBinders pat'
389 ; (grhss', fvs) <- bindSigTyVarsFV (concatMap sig_fn bndrs) $
390 rnGRHSs PatBindRhs grhss
392 ; return (L loc (PatBind pat' grhss' ty (trim fvs)), bndrs, pat_fvs `plusFV` fvs) }
394 rnBind sig_fn trim (L loc (FunBind name inf matches _))
396 do { new_name <- lookupLocatedBndrRn name
397 ; let plain_name = unLoc new_name
399 ; (matches', fvs) <- bindSigTyVarsFV (sig_fn plain_name) $
400 rnMatchGroup (FunRhs plain_name) matches
402 ; checkPrecMatch inf plain_name matches'
404 ; return (L loc (FunBind new_name inf matches' (trim fvs)), [plain_name], fvs)
409 @rnMethodBinds@ is used for the method bindings of a class and an instance
410 declaration. Like @rnBinds@ but without dependency analysis.
412 NOTA BENE: we record each {\em binder} of a method-bind group as a free variable.
413 That's crucial when dealing with an instance decl:
415 instance Foo (T a) where
418 This might be the {\em sole} occurrence of @op@ for an imported class @Foo@,
419 and unless @op@ occurs we won't treat the type signature of @op@ in the class
420 decl for @Foo@ as a source of instance-decl gates. But we should! Indeed,
421 in many ways the @op@ in an instance decl is just like an occurrence, not
425 rnMethodBinds :: Name -- Class name
426 -> [Name] -- Names for generic type variables
428 -> RnM (LHsBinds Name, FreeVars)
430 rnMethodBinds cls gen_tyvars binds
431 = foldM do_one (emptyBag,emptyFVs) (bagToList binds)
432 where do_one (binds,fvs) bind = do
433 (bind', fvs_bind) <- rnMethodBind cls gen_tyvars bind
434 return (bind' `unionBags` binds, fvs_bind `plusFV` fvs)
436 rnMethodBind cls gen_tyvars (L loc (FunBind name inf (MatchGroup matches _) _))
438 lookupLocatedInstDeclBndr cls name `thenM` \ sel_name ->
439 let plain_name = unLoc sel_name in
440 -- We use the selector name as the binder
442 mapFvRn (rn_match plain_name) matches `thenM` \ (new_matches, fvs) ->
444 new_group = MatchGroup new_matches placeHolderType
446 checkPrecMatch inf plain_name new_group `thenM_`
447 returnM (unitBag (L loc (FunBind sel_name inf new_group fvs)), fvs `addOneFV` plain_name)
448 -- The 'fvs' field isn't used for method binds
450 -- Truly gruesome; bring into scope the correct members of the generic
451 -- type variables. See comments in RnSource.rnSourceDecl(ClassDecl)
452 rn_match sel_name match@(L _ (Match (L _ (TypePat ty) : _) _ _))
453 = extendTyVarEnvFVRn gen_tvs $
454 rnMatch (FunRhs sel_name) match
456 tvs = map (rdrNameOcc.unLoc) (extractHsTyRdrTyVars ty)
457 gen_tvs = [tv | tv <- gen_tyvars, nameOccName tv `elem` tvs]
459 rn_match sel_name match = rnMatch (FunRhs sel_name) match
462 -- Can't handle method pattern-bindings which bind multiple methods.
463 rnMethodBind cls gen_tyvars mbind@(L loc (PatBind other_pat _ _ _))
464 = addLocErr mbind methodBindErr `thenM_`
465 returnM (emptyBag, emptyFVs)
469 %************************************************************************
471 \subsubsection[dep-Sigs]{Signatures (and user-pragmas for values)}
473 %************************************************************************
475 @renameSigs@ checks for:
477 \item more than one sig for one thing;
478 \item signatures given for things not bound here;
479 \item with suitably flaggery, that all top-level things have type signatures.
482 At the moment we don't gather free-var info from the types in
483 signatures. We'd only need this if we wanted to report unused tyvars.
486 renameSigs :: (LSig Name -> Bool) -> [LSig RdrName] -> RnM [LSig Name]
487 -- Renames the signatures and performs error checks
488 renameSigs ok_sig sigs
489 = do { sigs' <- rename_sigs sigs
490 ; check_sigs ok_sig sigs'
493 ----------------------
494 rename_sigs :: [LSig RdrName] -> RnM [LSig Name]
495 rename_sigs sigs = mappM (wrapLocM renameSig)
496 (filter (not . isFixityLSig) sigs)
497 -- Remove fixity sigs which have been dealt with already
499 ----------------------
500 check_sigs :: (LSig Name -> Bool) -> [LSig Name] -> RnM ()
501 -- Used for class and instance decls, as well as regular bindings
502 check_sigs ok_sig sigs
503 -- Check for (a) duplicate signatures
504 -- (b) signatures for things not in this group
505 = do { mappM_ unknownSigErr (filter (not . ok_sig) sigs')
506 ; mappM_ dupSigDeclErr (findDupsEq eqHsSig sigs') }
508 -- Don't complain about an unbound name again
509 sigs' = filterOut bad_name sigs
510 bad_name sig = case sigName sig of
511 Just n -> isUnboundName n
514 -- We use lookupLocatedSigOccRn in the signatures, which is a little bit unsatisfactory
515 -- because this won't work for:
516 -- instance Foo T where
519 -- We'll just rename the INLINE prag to refer to whatever other 'op'
520 -- is in scope. (I'm assuming that Baz.op isn't in scope unqualified.)
521 -- Doesn't seem worth much trouble to sort this.
523 renameSig :: Sig RdrName -> RnM (Sig Name)
524 -- FixitSig is renamed elsewhere.
525 renameSig (TypeSig v ty)
526 = lookupLocatedSigOccRn v `thenM` \ new_v ->
527 rnHsSigType (quotes (ppr v)) ty `thenM` \ new_ty ->
528 returnM (TypeSig new_v new_ty)
530 renameSig (SpecInstSig ty)
531 = rnLHsType (text "A SPECIALISE instance pragma") ty `thenM` \ new_ty ->
532 returnM (SpecInstSig new_ty)
534 renameSig (SpecSig v ty inl)
535 = lookupLocatedSigOccRn v `thenM` \ new_v ->
536 rnHsSigType (quotes (ppr v)) ty `thenM` \ new_ty ->
537 returnM (SpecSig new_v new_ty inl)
539 renameSig (InlineSig v s)
540 = lookupLocatedSigOccRn v `thenM` \ new_v ->
541 returnM (InlineSig new_v s)
545 ************************************************************************
549 ************************************************************************
552 rnMatchGroup :: HsMatchContext Name -> MatchGroup RdrName -> RnM (MatchGroup Name, FreeVars)
553 rnMatchGroup ctxt (MatchGroup ms _)
554 = mapFvRn (rnMatch ctxt) ms `thenM` \ (new_ms, ms_fvs) ->
555 returnM (MatchGroup new_ms placeHolderType, ms_fvs)
557 rnMatch :: HsMatchContext Name -> LMatch RdrName -> RnM (LMatch Name, FreeVars)
558 rnMatch ctxt = wrapLocFstM (rnMatch' ctxt)
560 rnMatch' ctxt match@(Match pats maybe_rhs_sig grhss)
562 -- Deal with the rhs type signature
563 bindPatSigTyVarsFV rhs_sig_tys $
564 doptM Opt_GlasgowExts `thenM` \ opt_GlasgowExts ->
565 (case maybe_rhs_sig of
566 Nothing -> returnM (Nothing, emptyFVs)
567 Just ty | opt_GlasgowExts -> rnHsTypeFVs doc_sig ty `thenM` \ (ty', ty_fvs) ->
568 returnM (Just ty', ty_fvs)
569 | otherwise -> addLocErr ty patSigErr `thenM_`
570 returnM (Nothing, emptyFVs)
571 ) `thenM` \ (maybe_rhs_sig', ty_fvs) ->
573 -- Now the main event
574 rnPatsAndThen ctxt pats $ \ pats' ->
575 rnGRHSs ctxt grhss `thenM` \ (grhss', grhss_fvs) ->
577 returnM (Match pats' maybe_rhs_sig' grhss', grhss_fvs `plusFV` ty_fvs)
578 -- The bindPatSigTyVarsFV and rnPatsAndThen will remove the bound FVs
580 rhs_sig_tys = case maybe_rhs_sig of
583 doc_sig = text "In a result type-signature"
587 %************************************************************************
589 \subsubsection{Guarded right-hand sides (GRHSs)}
591 %************************************************************************
594 rnGRHSs :: HsMatchContext Name -> GRHSs RdrName -> RnM (GRHSs Name, FreeVars)
596 rnGRHSs ctxt (GRHSs grhss binds)
597 = rnLocalBindsAndThen binds $ \ binds' ->
598 mapFvRn (rnGRHS ctxt) grhss `thenM` \ (grhss', fvGRHSs) ->
599 returnM (GRHSs grhss' binds', fvGRHSs)
601 rnGRHS :: HsMatchContext Name -> LGRHS RdrName -> RnM (LGRHS Name, FreeVars)
602 rnGRHS ctxt = wrapLocFstM (rnGRHS' ctxt)
604 rnGRHS' ctxt (GRHS guards rhs)
605 = do { opt_GlasgowExts <- doptM Opt_GlasgowExts
606 ; checkM (opt_GlasgowExts || is_standard_guard guards)
607 (addWarn (nonStdGuardErr guards))
609 ; ((guards', rhs'), fvs) <- rnStmts (PatGuard ctxt) guards $
611 ; return (GRHS guards' rhs', fvs) }
613 -- Standard Haskell 1.4 guards are just a single boolean
614 -- expression, rather than a list of qualifiers as in the
616 is_standard_guard [] = True
617 is_standard_guard [L _ (ExprStmt _ _ _)] = True
618 is_standard_guard other = False
621 %************************************************************************
623 \subsection{Error messages}
625 %************************************************************************
628 dupSigDeclErr sigs@(L loc sig : _)
630 vcat [ptext SLIT("Duplicate") <+> what_it_is <> colon,
631 nest 2 (vcat (map ppr_sig sigs))]
633 what_it_is = hsSigDoc sig
634 ppr_sig (L loc sig) = ppr loc <> colon <+> ppr sig
636 unknownSigErr (L loc sig)
638 sep [ptext SLIT("Misplaced") <+> what_it_is <> colon, ppr sig]
640 what_it_is = hsSigDoc sig
643 = addWarnAt (mkSrcSpan loc loc) $
644 sep [ptext SLIT("Definition but no type signature for"), quotes (ppr var)]
646 loc = nameSrcLoc var -- TODO: make a proper span
649 = hang (ptext SLIT("Pattern bindings (except simple variables) not allowed in instance declarations"))
652 bindsInHsBootFile mbinds
653 = hang (ptext SLIT("Bindings in hs-boot files are not allowed"))
658 SLIT("accepting non-standard pattern guards (-fglasgow-exts to suppress this message)")