3 % (c) The University of Glasgow, 1992-2006
6 Here we collect a variety of helper functions that construct or
7 analyse HsSyn. All these functions deal with generic HsSyn; functions
8 which deal with the intantiated versions are located elsewhere:
10 Parameterised by Module
11 ---------------- -------------
12 RdrName parser/RdrHsSyn
19 mkHsPar, mkHsApp, mkHsConApp, mkSimpleHsAlt,
20 mkSimpleMatch, unguardedGRHSs, unguardedRHS,
21 mkMatchGroup, mkMatch, mkHsLam,
22 mkHsWrap, mkLHsWrap, mkHsWrapCoI, coiToHsWrapper, mkHsDictLet,
25 nlHsTyApp, nlHsVar, nlHsLit, nlHsApp, nlHsApps, nlHsIntLit, nlHsVarApps,
26 nlHsDo, nlHsOpApp, nlHsLam, nlHsPar, nlHsIf, nlHsCase, nlList,
27 mkLHsTupleExpr, mkLHsVarTuple, missingTupArg,
30 mkFunBind, mkVarBind, mkHsVarBind, mk_easy_FunBind, mk_FunBind,
33 mkHsIntegral, mkHsFractional, mkHsIsString, mkHsString,
36 mkNPat, mkNPlusKPat, nlVarPat, nlLitPat, nlConVarPat, nlConPat, nlInfixConPat,
37 nlNullaryConPat, nlWildConPat, nlWildPat, nlTuplePat,
40 mkHsAppTy, userHsTyVarBndrs,
41 nlHsAppTy, nlHsTyVar, nlHsFunTy, nlHsTyConApp,
44 mkTransformStmt, mkTransformByStmt, mkExprStmt, mkBindStmt,
45 mkGroupUsingStmt, mkGroupByStmt, mkGroupByUsingStmt,
46 emptyRecStmt, mkRecStmt,
49 unqualSplice, mkHsSpliceTy, mkHsSplice, mkHsQuasiQuote, unqualQuasiQuote,
55 collectLocalBinders, collectHsValBinders,
56 collectHsBindsBinders, collectHsBindBinders, collectMethodBinders,
57 collectPatBinders, collectPatsBinders,
58 collectLStmtsBinders, collectStmtsBinders,
59 collectLStmtBinders, collectStmtBinders,
60 collectSigTysFromPats, collectSigTysFromPat
85 %************************************************************************
87 Some useful helpers for constructing syntax
89 %************************************************************************
91 These functions attempt to construct a not-completely-useless SrcSpan
92 from their components, compared with the nl* functions below which
93 just attach noSrcSpan to everything.
96 mkHsPar :: LHsExpr id -> LHsExpr id
97 mkHsPar e = L (getLoc e) (HsPar e)
99 mkSimpleMatch :: [LPat id] -> LHsExpr id -> LMatch id
100 mkSimpleMatch pats rhs
102 Match pats Nothing (unguardedGRHSs rhs)
106 (pat:_) -> combineSrcSpans (getLoc pat) (getLoc rhs)
108 unguardedGRHSs :: LHsExpr id -> GRHSs id
109 unguardedGRHSs rhs = GRHSs (unguardedRHS rhs) emptyLocalBinds
111 unguardedRHS :: LHsExpr id -> [LGRHS id]
112 unguardedRHS rhs@(L loc _) = [L loc (GRHS [] rhs)]
114 mkHsAppTy :: LHsType name -> LHsType name -> LHsType name
115 mkHsAppTy t1 t2 = addCLoc t1 t2 (HsAppTy t1 t2)
117 mkHsApp :: LHsExpr name -> LHsExpr name -> LHsExpr name
118 mkHsApp e1 e2 = addCLoc e1 e2 (HsApp e1 e2)
120 nlHsTyApp :: name -> [Type] -> LHsExpr name
121 nlHsTyApp fun_id tys = noLoc (HsWrap (mkWpTyApps tys) (HsVar fun_id))
123 mkLHsWrap :: HsWrapper -> LHsExpr id -> LHsExpr id
124 mkLHsWrap co_fn (L loc e) = L loc (mkHsWrap co_fn e)
126 mkHsWrap :: HsWrapper -> HsExpr id -> HsExpr id
127 mkHsWrap co_fn e | isIdHsWrapper co_fn = e
128 | otherwise = HsWrap co_fn e
130 mkHsWrapCoI :: CoercionI -> HsExpr id -> HsExpr id
131 mkHsWrapCoI IdCo e = e
132 mkHsWrapCoI (ACo co) e = mkHsWrap (WpCast co) e
134 coiToHsWrapper :: CoercionI -> HsWrapper
135 coiToHsWrapper IdCo = idHsWrapper
136 coiToHsWrapper (ACo co) = WpCast co
138 mkHsLam :: [LPat id] -> LHsExpr id -> LHsExpr id
139 mkHsLam pats body = mkHsPar (L (getLoc body) (HsLam matches))
141 matches = mkMatchGroup [mkSimpleMatch pats body]
143 mkMatchGroup :: [LMatch id] -> MatchGroup id
144 mkMatchGroup matches = MatchGroup matches placeHolderType
146 mkHsDictLet :: LHsBinds Id -> LHsExpr Id -> LHsExpr Id
147 -- Used for the dictionary bindings gotten from TcSimplify
148 -- We make them recursive to be on the safe side
149 mkHsDictLet binds expr
150 | isEmptyLHsBinds binds = expr
151 | otherwise = L (getLoc expr) (HsLet (HsValBinds val_binds) expr)
153 val_binds = ValBindsOut [(Recursive, binds)] []
155 mkHsConApp :: DataCon -> [Type] -> [HsExpr Id] -> LHsExpr Id
156 -- Used for constructing dictionary terms etc, so no locations
157 mkHsConApp data_con tys args
158 = foldl mk_app (nlHsTyApp (dataConWrapId data_con) tys) args
160 mk_app f a = noLoc (HsApp f (noLoc a))
162 mkSimpleHsAlt :: LPat id -> LHsExpr id -> LMatch id
163 -- A simple lambda with a single pattern, no binds, no guards; pre-typechecking
164 mkSimpleHsAlt pat expr
165 = mkSimpleMatch [pat] expr
167 -------------------------------
168 -- These are the bits of syntax that contain rebindable names
169 -- See RnEnv.lookupSyntaxName
171 mkHsIntegral :: Integer -> PostTcType -> HsOverLit id
172 mkHsFractional :: Rational -> PostTcType -> HsOverLit id
173 mkHsIsString :: FastString -> PostTcType -> HsOverLit id
174 mkHsDo :: HsStmtContext Name -> [LStmt id] -> LHsExpr id -> HsExpr id
176 mkNPat :: HsOverLit id -> Maybe (SyntaxExpr id) -> Pat id
177 mkNPlusKPat :: Located id -> HsOverLit id -> Pat id
179 mkTransformStmt :: [LStmt idL] -> LHsExpr idR -> StmtLR idL idR
180 mkTransformByStmt :: [LStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR
182 mkExprStmt :: LHsExpr idR -> StmtLR idL idR
183 mkBindStmt :: LPat idL -> LHsExpr idR -> StmtLR idL idR
185 emptyRecStmt :: StmtLR idL idR
186 mkRecStmt :: [LStmtLR idL idR] -> StmtLR idL idR
189 mkHsIntegral i = OverLit (HsIntegral i) noRebindableInfo noSyntaxExpr
190 mkHsFractional f = OverLit (HsFractional f) noRebindableInfo noSyntaxExpr
191 mkHsIsString s = OverLit (HsIsString s) noRebindableInfo noSyntaxExpr
193 noRebindableInfo :: Bool
194 noRebindableInfo = error "noRebindableInfo" -- Just another placeholder;
196 mkHsDo ctxt stmts body = HsDo ctxt stmts body placeHolderType
198 mkNPat lit neg = NPat lit neg noSyntaxExpr
199 mkNPlusKPat id lit = NPlusKPat id lit noSyntaxExpr noSyntaxExpr
201 mkTransformStmt stmts usingExpr = TransformStmt stmts [] usingExpr Nothing
202 mkTransformByStmt stmts usingExpr byExpr = TransformStmt stmts [] usingExpr (Just byExpr)
204 mkGroupUsingStmt :: [LStmt idL] -> LHsExpr idR -> StmtLR idL idR
205 mkGroupByStmt :: [LStmt idL] -> LHsExpr idR -> StmtLR idL idR
206 mkGroupByUsingStmt :: [LStmt idL] -> LHsExpr idR -> LHsExpr idR -> StmtLR idL idR
208 mkGroupUsingStmt stmts usingExpr = GroupStmt stmts [] Nothing (Left usingExpr)
209 mkGroupByStmt stmts byExpr = GroupStmt stmts [] (Just byExpr) (Right noSyntaxExpr)
210 mkGroupByUsingStmt stmts byExpr usingExpr = GroupStmt stmts [] (Just byExpr) (Left usingExpr)
212 mkExprStmt expr = ExprStmt expr noSyntaxExpr placeHolderType
213 mkBindStmt pat expr = BindStmt pat expr noSyntaxExpr noSyntaxExpr
215 emptyRecStmt = RecStmt { recS_stmts = [], recS_later_ids = [], recS_rec_ids = []
216 , recS_ret_fn = noSyntaxExpr, recS_mfix_fn = noSyntaxExpr
217 , recS_bind_fn = noSyntaxExpr
218 , recS_rec_rets = [], recS_dicts = emptyLHsBinds }
220 mkRecStmt stmts = emptyRecStmt { recS_stmts = stmts }
222 -------------------------------
223 --- A useful function for building @OpApps@. The operator is always a
224 -- variable, and we don't know the fixity yet.
225 mkHsOpApp :: LHsExpr id -> id -> LHsExpr id -> HsExpr id
226 mkHsOpApp e1 op e2 = OpApp e1 (noLoc (HsVar op)) (error "mkOpApp:fixity") e2
228 mkHsSplice :: LHsExpr RdrName -> HsSplice RdrName
229 mkHsSplice e = HsSplice unqualSplice e
231 mkHsSpliceTy :: LHsExpr RdrName -> HsType RdrName
232 mkHsSpliceTy e = HsSpliceTy (mkHsSplice e) emptyFVs placeHolderKind
234 unqualSplice :: RdrName
235 unqualSplice = mkRdrUnqual (mkVarOccFS (fsLit "splice"))
236 -- A name (uniquified later) to
237 -- identify the splice
239 mkHsQuasiQuote :: RdrName -> SrcSpan -> FastString -> HsQuasiQuote RdrName
240 mkHsQuasiQuote quoter span quote = HsQuasiQuote quoter span quote
242 unqualQuasiQuote :: RdrName
243 unqualQuasiQuote = mkRdrUnqual (mkVarOccFS (fsLit "quasiquote"))
244 -- A name (uniquified later) to
245 -- identify the quasi-quote
247 mkHsString :: String -> HsLit
248 mkHsString s = HsString (mkFastString s)
251 userHsTyVarBndrs :: [Located name] -> [Located (HsTyVarBndr name)]
252 userHsTyVarBndrs bndrs = [ L loc (UserTyVar v placeHolderKind) | L loc v <- bndrs ]
256 %************************************************************************
258 Constructing syntax with no location info
260 %************************************************************************
263 nlHsVar :: id -> LHsExpr id
264 nlHsVar n = noLoc (HsVar n)
266 nlHsLit :: HsLit -> LHsExpr id
267 nlHsLit n = noLoc (HsLit n)
269 nlVarPat :: id -> LPat id
270 nlVarPat n = noLoc (VarPat n)
272 nlLitPat :: HsLit -> LPat id
273 nlLitPat l = noLoc (LitPat l)
275 nlHsApp :: LHsExpr id -> LHsExpr id -> LHsExpr id
276 nlHsApp f x = noLoc (HsApp f x)
278 nlHsIntLit :: Integer -> LHsExpr id
279 nlHsIntLit n = noLoc (HsLit (HsInt n))
281 nlHsApps :: id -> [LHsExpr id] -> LHsExpr id
282 nlHsApps f xs = foldl nlHsApp (nlHsVar f) xs
284 nlHsVarApps :: id -> [id] -> LHsExpr id
285 nlHsVarApps f xs = noLoc (foldl mk (HsVar f) (map HsVar xs))
287 mk f a = HsApp (noLoc f) (noLoc a)
289 nlConVarPat :: id -> [id] -> LPat id
290 nlConVarPat con vars = nlConPat con (map nlVarPat vars)
292 nlInfixConPat :: id -> LPat id -> LPat id -> LPat id
293 nlInfixConPat con l r = noLoc (ConPatIn (noLoc con) (InfixCon l r))
295 nlConPat :: id -> [LPat id] -> LPat id
296 nlConPat con pats = noLoc (ConPatIn (noLoc con) (PrefixCon pats))
298 nlNullaryConPat :: id -> LPat id
299 nlNullaryConPat con = noLoc (ConPatIn (noLoc con) (PrefixCon []))
301 nlWildConPat :: DataCon -> LPat RdrName
302 nlWildConPat con = noLoc (ConPatIn (noLoc (getRdrName con))
303 (PrefixCon (nOfThem (dataConSourceArity con) nlWildPat)))
306 nlWildPat = noLoc (WildPat placeHolderType) -- Pre-typechecking
308 nlHsDo :: HsStmtContext Name -> [LStmt id] -> LHsExpr id -> LHsExpr id
309 nlHsDo ctxt stmts body = noLoc (mkHsDo ctxt stmts body)
311 nlHsOpApp :: LHsExpr id -> id -> LHsExpr id -> LHsExpr id
312 nlHsOpApp e1 op e2 = noLoc (mkHsOpApp e1 op e2)
314 nlHsLam :: LMatch id -> LHsExpr id
315 nlHsPar :: LHsExpr id -> LHsExpr id
316 nlHsIf :: LHsExpr id -> LHsExpr id -> LHsExpr id -> LHsExpr id
317 nlHsCase :: LHsExpr id -> [LMatch id] -> LHsExpr id
318 nlList :: [LHsExpr id] -> LHsExpr id
320 nlHsLam match = noLoc (HsLam (mkMatchGroup [match]))
321 nlHsPar e = noLoc (HsPar e)
322 nlHsIf cond true false = noLoc (HsIf cond true false)
323 nlHsCase expr matches = noLoc (HsCase expr (mkMatchGroup matches))
324 nlList exprs = noLoc (ExplicitList placeHolderType exprs)
326 nlHsAppTy :: LHsType name -> LHsType name -> LHsType name
327 nlHsTyVar :: name -> LHsType name
328 nlHsFunTy :: LHsType name -> LHsType name -> LHsType name
330 nlHsAppTy f t = noLoc (HsAppTy f t)
331 nlHsTyVar x = noLoc (HsTyVar x)
332 nlHsFunTy a b = noLoc (HsFunTy a b)
334 nlHsTyConApp :: name -> [LHsType name] -> LHsType name
335 nlHsTyConApp tycon tys = foldl nlHsAppTy (nlHsTyVar tycon) tys
338 Tuples. All these functions are *pre-typechecker* because they lack
342 mkLHsTupleExpr :: [LHsExpr a] -> LHsExpr a
343 -- Makes a pre-typechecker boxed tuple, deals with 1 case
344 mkLHsTupleExpr [e] = e
345 mkLHsTupleExpr es = noLoc $ ExplicitTuple (map Present es) Boxed
347 mkLHsVarTuple :: [a] -> LHsExpr a
348 mkLHsVarTuple ids = mkLHsTupleExpr (map nlHsVar ids)
350 nlTuplePat :: [LPat id] -> Boxity -> LPat id
351 nlTuplePat pats box = noLoc (TuplePat pats box placeHolderType)
353 missingTupArg :: HsTupArg a
354 missingTupArg = Missing placeHolderType
357 %************************************************************************
359 Bindings; with a location at the top
361 %************************************************************************
364 mkFunBind :: Located id -> [LMatch id] -> HsBind id
365 -- Not infix, with place holders for coercion and free vars
366 mkFunBind fn ms = FunBind { fun_id = fn, fun_infix = False, fun_matches = mkMatchGroup ms,
367 fun_co_fn = idHsWrapper, bind_fvs = placeHolderNames,
371 mkHsVarBind :: SrcSpan -> id -> LHsExpr id -> LHsBind id
372 mkHsVarBind loc var rhs = mk_easy_FunBind loc var [] rhs
374 mkVarBind :: id -> LHsExpr id -> LHsBind id
375 mkVarBind var rhs = L (getLoc rhs) $
376 VarBind { var_id = var, var_rhs = rhs, var_inline = False }
379 mk_easy_FunBind :: SrcSpan -> id -> [LPat id]
380 -> LHsExpr id -> LHsBind id
382 mk_easy_FunBind loc fun pats expr
383 = L loc $ mkFunBind (L loc fun) [mkMatch pats expr emptyLocalBinds]
386 mk_FunBind :: SrcSpan -> id
387 -> [([LPat id], LHsExpr id)]
390 mk_FunBind _ _ [] = panic "TcGenDeriv:mk_FunBind"
391 mk_FunBind loc fun pats_and_exprs
392 = L loc $ mkFunBind (L loc fun) matches
394 matches = [mkMatch p e emptyLocalBinds | (p,e) <-pats_and_exprs]
397 mkMatch :: [LPat id] -> LHsExpr id -> HsLocalBinds id -> LMatch id
398 mkMatch pats expr binds
399 = noLoc (Match (map paren pats) Nothing
400 (GRHSs (unguardedRHS expr) binds))
402 paren lp@(L l p) | hsPatNeedsParens p = L l (ParPat lp)
407 %************************************************************************
411 %************************************************************************
413 Get all the binders in some HsBindGroups, IN THE ORDER OF APPEARANCE. eg.
421 it should return [x, y, f, a, b] (remember, order important).
423 Note [Collect binders only after renaming]
424 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425 These functions should only be used on HsSyn *after* the renamer,
426 to reuturn a [Name] or [Id]. Before renaming the record punning
427 and wild-card mechanism makes it hard to know what is bound.
428 So these functions should not be applied to (HsSyn RdrName)
431 ----------------- Bindings --------------------------
432 collectLocalBinders :: HsLocalBindsLR idL idR -> [idL]
433 collectLocalBinders (HsValBinds val_binds) = collectHsValBinders val_binds
434 collectLocalBinders (HsIPBinds _) = []
435 collectLocalBinders EmptyLocalBinds = []
437 collectHsValBinders :: HsValBindsLR idL idR -> [idL]
438 collectHsValBinders (ValBindsIn binds _) = collectHsBindsBinders binds
439 collectHsValBinders (ValBindsOut binds _) = foldr collect_one [] binds
441 collect_one (_,binds) acc = collect_binds binds acc
443 collectHsBindBinders :: HsBindLR idL idR -> [idL]
444 collectHsBindBinders b = collect_bind b []
446 collect_bind :: HsBindLR idL idR -> [idL] -> [idL]
447 collect_bind (PatBind { pat_lhs = p }) acc = collect_lpat p acc
448 collect_bind (FunBind { fun_id = L _ f }) acc = f : acc
449 collect_bind (VarBind { var_id = f }) acc = f : acc
450 collect_bind (AbsBinds { abs_exports = dbinds, abs_binds = _binds }) acc
451 = [dp | (_,dp,_,_) <- dbinds] ++ acc
452 -- ++ foldr collect_bind acc binds
453 -- I don't think we want the binders from the nested binds
454 -- The only time we collect binders from a typechecked
455 -- binding (hence see AbsBinds) is in zonking in TcHsSyn
457 collectHsBindsBinders :: LHsBindsLR idL idR -> [idL]
458 collectHsBindsBinders binds = collect_binds binds []
460 collect_binds :: LHsBindsLR idL idR -> [idL] -> [idL]
461 collect_binds binds acc = foldrBag (collect_bind . unLoc) acc binds
463 collectMethodBinders :: LHsBindsLR RdrName idR -> [Located RdrName]
464 -- Used exclusively for the bindings of an instance decl which are all FunBinds
465 collectMethodBinders binds = foldrBag get [] binds
467 get (L _ (FunBind { fun_id = f })) fs = f : fs
469 -- Someone else complains about non-FunBinds
471 ----------------- Statements --------------------------
472 collectLStmtsBinders :: [LStmtLR idL idR] -> [idL]
473 collectLStmtsBinders = concatMap collectLStmtBinders
475 collectStmtsBinders :: [StmtLR idL idR] -> [idL]
476 collectStmtsBinders = concatMap collectStmtBinders
478 collectLStmtBinders :: LStmtLR idL idR -> [idL]
479 collectLStmtBinders = collectStmtBinders . unLoc
481 collectStmtBinders :: StmtLR idL idR -> [idL]
482 -- Id Binders for a Stmt... [but what about pattern-sig type vars]?
483 collectStmtBinders (BindStmt pat _ _ _) = collectPatBinders pat
484 collectStmtBinders (LetStmt binds) = collectLocalBinders binds
485 collectStmtBinders (ExprStmt _ _ _) = []
486 collectStmtBinders (ParStmt xs) = collectLStmtsBinders
488 collectStmtBinders (TransformStmt stmts _ _ _) = collectLStmtsBinders stmts
489 collectStmtBinders (GroupStmt stmts _ _ _) = collectLStmtsBinders stmts
490 collectStmtBinders (RecStmt { recS_stmts = ss }) = collectLStmtsBinders ss
493 ----------------- Patterns --------------------------
494 collectPatBinders :: LPat a -> [a]
495 collectPatBinders pat = collect_lpat pat []
497 collectPatsBinders :: [LPat a] -> [a]
498 collectPatsBinders pats = foldr collect_lpat [] pats
501 collect_lpat :: LPat name -> [name] -> [name]
502 collect_lpat (L _ pat) bndrs
505 go (VarPat var) = var : bndrs
506 go (VarPatOut var bs) = var : collect_binds bs bndrs
507 go (WildPat _) = bndrs
508 go (LazyPat pat) = collect_lpat pat bndrs
509 go (BangPat pat) = collect_lpat pat bndrs
510 go (AsPat (L _ a) pat) = a : collect_lpat pat bndrs
511 go (ViewPat _ pat _) = collect_lpat pat bndrs
512 go (ParPat pat) = collect_lpat pat bndrs
514 go (ListPat pats _) = foldr collect_lpat bndrs pats
515 go (PArrPat pats _) = foldr collect_lpat bndrs pats
516 go (TuplePat pats _ _) = foldr collect_lpat bndrs pats
518 go (ConPatIn _ ps) = foldr collect_lpat bndrs (hsConPatArgs ps)
519 go (ConPatOut {pat_args=ps}) = foldr collect_lpat bndrs (hsConPatArgs ps)
520 -- See Note [Dictionary binders in ConPatOut]
521 go (LitPat _) = bndrs
522 go (NPat _ _ _) = bndrs
523 go (NPlusKPat (L _ n) _ _ _) = n : bndrs
525 go (SigPatIn pat _) = collect_lpat pat bndrs
526 go (SigPatOut pat _) = collect_lpat pat bndrs
527 go (QuasiQuotePat _) = bndrs
528 go (TypePat _) = bndrs
529 go (CoPat _ pat _) = go pat
532 Note [Dictionary binders in ConPatOut] See also same Note in DsArrows
533 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
534 Do *not* gather (a) dictionary and (b) dictionary bindings as binders
535 of a ConPatOut pattern. For most calls it doesn't matter, because
536 it's pre-typechecker and there are no ConPatOuts. But it does matter
537 more in the desugarer; for example, DsUtils.mkSelectorBinds uses
538 collectPatBinders. In a lazy pattern, for example f ~(C x y) = ...,
539 we want to generate bindings for x,y but not for dictionaries bound by
540 C. (The type checker ensures they would not be used.)
542 Desugaring of arrow case expressions needs these bindings (see DsArrows
543 and arrowcase1), but SPJ (Jan 2007) says it's safer for it to use its
544 own pat-binder-collector:
546 Here's the problem. Consider
549 C :: Num a => a -> Int -> T a
551 f ~(C (n+1) m) = (n,m)
553 Here, the pattern (C (n+1)) binds a hidden dictionary (d::Num a),
554 and *also* uses that dictionary to match the (n+1) pattern. Yet, the
555 variables bound by the lazy pattern are n,m, *not* the dictionary d.
556 So in mkSelectorBinds in DsUtils, we want just m,n as the variables bound.
558 %************************************************************************
560 Collecting type signatures from patterns
562 %************************************************************************
565 collectSigTysFromPats :: [InPat name] -> [LHsType name]
566 collectSigTysFromPats pats = foldr collect_sig_lpat [] pats
568 collectSigTysFromPat :: InPat name -> [LHsType name]
569 collectSigTysFromPat pat = collect_sig_lpat pat []
571 collect_sig_lpat :: InPat name -> [LHsType name] -> [LHsType name]
572 collect_sig_lpat pat acc = collect_sig_pat (unLoc pat) acc
574 collect_sig_pat :: Pat name -> [LHsType name] -> [LHsType name]
575 collect_sig_pat (SigPatIn pat ty) acc = collect_sig_lpat pat (ty:acc)
576 collect_sig_pat (TypePat ty) acc = ty:acc
578 collect_sig_pat (LazyPat pat) acc = collect_sig_lpat pat acc
579 collect_sig_pat (BangPat pat) acc = collect_sig_lpat pat acc
580 collect_sig_pat (AsPat _ pat) acc = collect_sig_lpat pat acc
581 collect_sig_pat (ParPat pat) acc = collect_sig_lpat pat acc
582 collect_sig_pat (ListPat pats _) acc = foldr collect_sig_lpat acc pats
583 collect_sig_pat (PArrPat pats _) acc = foldr collect_sig_lpat acc pats
584 collect_sig_pat (TuplePat pats _ _) acc = foldr collect_sig_lpat acc pats
585 collect_sig_pat (ConPatIn _ ps) acc = foldr collect_sig_lpat acc (hsConPatArgs ps)
586 collect_sig_pat _ acc = acc -- Literals, vars, wildcard