2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
4 \section[RnExpr]{Renaming of expressions}
6 Basically dependency analysis.
8 Handles @Match@, @GRHSsAndBinds@, @HsExpr@, and @Qualifier@ datatypes. In
9 general, all of these functions return a renamed thing, and a set of
13 #include "HsVersions.h"
16 rnMatch, rnGRHSsAndBinds, rnPat,
21 IMPORT_DELOOPER(RnLoop) -- break the RnPass/RnExpr/RnBinds loops
28 import PrelInfo ( numClass_RDR, fractionalClass_RDR, eqClass_RDR, ccallableClass_RDR,
29 creturnableClass_RDR, monadZeroClass_RDR, enumClass_RDR, ordClass_RDR,
32 import TysPrim ( charPrimTyCon, addrPrimTyCon, intPrimTyCon,
33 floatPrimTyCon, doublePrimTyCon
35 import TyCon ( TyCon )
37 import ErrUtils ( addErrLoc, addShortErrLocLine )
40 import Unique ( Unique, otherwiseIdKey )
41 import UniqFM ( lookupUFM{-, ufmToList ToDo:rm-} )
42 import UniqSet ( emptyUniqSet, unitUniqSet,
43 unionUniqSets, unionManyUniqSets,
46 import PprStyle ( PprStyle(..) )
47 import Util ( Ord3(..), removeDups, panic, pprPanic, assertPanic )
51 *********************************************************
55 *********************************************************
58 rnPat :: RdrNamePat -> RnMS s RenamedPat
60 rnPat WildPatIn = returnRn WildPatIn
63 = lookupBndrRn name `thenRn` \ vname ->
64 returnRn (VarPatIn vname)
67 = litOccurrence lit `thenRn_`
68 lookupImplicitOccRn eqClass_RDR `thenRn_` -- Needed to find equality on pattern
69 returnRn (LitPatIn lit)
72 = rnPat pat `thenRn` \ pat' ->
73 returnRn (LazyPatIn pat')
75 rnPat (AsPatIn name pat)
76 = rnPat pat `thenRn` \ pat' ->
77 lookupBndrRn name `thenRn` \ vname ->
78 returnRn (AsPatIn vname pat')
80 rnPat (ConPatIn con pats)
81 = lookupOccRn con `thenRn` \ con' ->
82 mapRn rnPat pats `thenRn` \ patslist ->
83 returnRn (ConPatIn con' patslist)
85 rnPat (ConOpPatIn pat1 con _ pat2)
86 = rnPat pat1 `thenRn` \ pat1' ->
87 lookupOccRn con `thenRn` \ con' ->
88 lookupFixity con `thenRn` \ fixity ->
89 rnPat pat2 `thenRn` \ pat2' ->
90 mkConOpPatRn pat1' con' fixity pat2'
92 -- Negated patters can only be literals, and they are dealt with
93 -- by negating the literal at compile time, not by using the negation
94 -- operation in Num. So we don't need to make an implicit reference
96 rnPat neg@(NegPatIn pat)
97 = checkRn (valid_neg_pat pat) (negPatErr neg)
99 rnPat pat `thenRn` \ pat' ->
100 returnRn (NegPatIn pat')
102 valid_neg_pat (LitPatIn (HsInt _)) = True
103 valid_neg_pat (LitPatIn (HsFrac _)) = True
104 valid_neg_pat _ = False
107 = rnPat pat `thenRn` \ pat' ->
108 returnRn (ParPatIn pat')
110 rnPat (NPlusKPatIn name lit)
111 = litOccurrence lit `thenRn_`
112 lookupImplicitOccRn ordClass_RDR `thenRn_`
113 lookupBndrRn name `thenRn` \ name' ->
114 returnRn (NPlusKPatIn name' lit)
116 rnPat (ListPatIn pats)
117 = addImplicitOccRn listType_name `thenRn_`
118 mapRn rnPat pats `thenRn` \ patslist ->
119 returnRn (ListPatIn patslist)
121 rnPat (TuplePatIn pats)
122 = addImplicitOccRn (tupleType_name (length pats)) `thenRn_`
123 mapRn rnPat pats `thenRn` \ patslist ->
124 returnRn (TuplePatIn patslist)
126 rnPat (RecPatIn con rpats)
127 = lookupOccRn con `thenRn` \ con' ->
128 rnRpats rpats `thenRn` \ rpats' ->
129 returnRn (RecPatIn con' rpats')
132 ************************************************************************
136 ************************************************************************
139 rnMatch :: RdrNameMatch -> RnMS s (RenamedMatch, FreeVars)
141 rnMatch (PatMatch pat match)
142 = bindLocalsRn "pattern" binders $ \ new_binders ->
143 rnPat pat `thenRn` \ pat' ->
144 rnMatch match `thenRn` \ (match', fvMatch) ->
145 returnRn (PatMatch pat' match', fvMatch `minusNameSet` mkNameSet new_binders)
147 binders = collectPatBinders pat
149 rnMatch (GRHSMatch grhss_and_binds)
150 = rnGRHSsAndBinds grhss_and_binds `thenRn` \ (grhss_and_binds', fvs) ->
151 returnRn (GRHSMatch grhss_and_binds', fvs)
154 %************************************************************************
156 \subsubsection{Guarded right-hand sides (GRHSsAndBinds)}
158 %************************************************************************
161 rnGRHSsAndBinds :: RdrNameGRHSsAndBinds -> RnMS s (RenamedGRHSsAndBinds, FreeVars)
163 rnGRHSsAndBinds (GRHSsAndBindsIn grhss binds)
164 = rnBinds binds $ \ binds' ->
165 rnGRHSs grhss `thenRn` \ (grhss', fvGRHS) ->
166 returnRn (GRHSsAndBindsIn grhss' binds', fvGRHS)
168 rnGRHSs [] = returnRn ([], emptyNameSet)
171 = rnGRHS grhs `thenRn` \ (grhs', fvs) ->
172 rnGRHSs grhss `thenRn` \ (grhss', fvss) ->
173 returnRn (grhs' : grhss', fvs `unionNameSets` fvss)
175 rnGRHS (GRHS guard expr locn)
176 = pushSrcLocRn locn $
177 rnExpr guard `thenRn` \ (guard', fvsg) ->
178 rnExpr expr `thenRn` \ (expr', fvse) ->
180 -- Turn an "otherwise" guard into an OtherwiseGRHS.
181 -- This is the first moment that we can be sure we havn't got a shadowed binding
183 let grhs' = case guard' of
184 HsVar v | uniqueOf v == otherwiseIdKey -> OtherwiseGRHS expr' locn
185 other -> GRHS guard' expr' locn
187 returnRn (grhs', fvsg `unionNameSets` fvse)
189 rnGRHS (OtherwiseGRHS expr locn)
190 = pushSrcLocRn locn $
191 rnExpr expr `thenRn` \ (expr', fvs) ->
192 returnRn (OtherwiseGRHS expr' locn, fvs)
195 %************************************************************************
197 \subsubsection{Expressions}
199 %************************************************************************
202 rnExprs :: [RdrNameHsExpr] -> RnMS s ([RenamedHsExpr], FreeVars)
204 rnExprs' ls [] `thenRn` \ (exprs, fvExprs) ->
205 returnRn (exprs, unionManyNameSets fvExprs)
207 rnExprs' [] acc = returnRn ([], acc)
208 rnExprs' (expr:exprs) acc
209 = rnExpr expr `thenRn` \ (expr', fvExpr) ->
210 rnExprs' exprs (fvExpr:acc) `thenRn` \ (exprs', fvExprs) ->
211 returnRn (expr':exprs', fvExprs)
214 Variables. We look up the variable and return the resulting name. The
215 interesting question is what the free-variable set should be. We
216 don't want to return imported or prelude things as free vars. So we
217 look at the Name returned from the lookup, and make it part of the
218 free-var set iff if it's a LocallyDefined Name.
222 rnExpr :: RdrNameHsExpr -> RnMS s (RenamedHsExpr, FreeVars)
225 = lookupOccRn v `thenRn` \ vname ->
226 returnRn (HsVar vname, if isLocallyDefined vname
227 then unitNameSet vname
231 = litOccurrence lit `thenRn_`
232 returnRn (HsLit lit, emptyNameSet)
235 = rnMatch match `thenRn` \ (match', fvMatch) ->
236 returnRn (HsLam match', fvMatch)
238 rnExpr (HsApp fun arg)
239 = rnExpr fun `thenRn` \ (fun',fvFun) ->
240 rnExpr arg `thenRn` \ (arg',fvArg) ->
241 returnRn (HsApp fun' arg', fvFun `unionNameSets` fvArg)
243 rnExpr (OpApp e1 op@(HsVar op_name) _ e2)
244 = rnExpr e1 `thenRn` \ (e1', fv_e1) ->
245 rnExpr e2 `thenRn` \ (e2', fv_e2) ->
246 rnExpr op `thenRn` \ (op', fv_op) ->
249 lookupFixity op_name `thenRn` \ fixity ->
250 getModeRn `thenRn` \ mode ->
252 SourceMode -> mkOpAppRn e1' op' fixity e2'
253 InterfaceMode -> returnRn (OpApp e1' op' fixity e2')
254 ) `thenRn` \ final_e ->
257 fv_e1 `unionNameSets` fv_op `unionNameSets` fv_e2)
260 = rnExpr e `thenRn` \ (e', fv_e) ->
261 lookupImplicitOccRn negate_RDR `thenRn` \ neg ->
262 getModeRn `thenRn` \ mode ->
263 mkNegAppRn mode e' (HsVar neg) `thenRn` \ final_e ->
264 returnRn (final_e, fv_e)
267 = rnExpr e `thenRn` \ (e', fvs_e) ->
268 returnRn (HsPar e', fvs_e)
270 rnExpr (SectionL expr op)
271 = rnExpr expr `thenRn` \ (expr', fvs_expr) ->
272 rnExpr op `thenRn` \ (op', fvs_op) ->
273 returnRn (SectionL expr' op', fvs_op `unionNameSets` fvs_expr)
275 rnExpr (SectionR op expr)
276 = rnExpr op `thenRn` \ (op', fvs_op) ->
277 rnExpr expr `thenRn` \ (expr', fvs_expr) ->
278 returnRn (SectionR op' expr', fvs_op `unionNameSets` fvs_expr)
280 rnExpr (CCall fun args may_gc is_casm fake_result_ty)
281 = lookupImplicitOccRn ccallableClass_RDR `thenRn_`
282 lookupImplicitOccRn creturnableClass_RDR `thenRn_`
283 rnExprs args `thenRn` \ (args', fvs_args) ->
284 returnRn (CCall fun args' may_gc is_casm fake_result_ty, fvs_args)
286 rnExpr (HsSCC label expr)
287 = rnExpr expr `thenRn` \ (expr', fvs_expr) ->
288 returnRn (HsSCC label expr', fvs_expr)
290 rnExpr (HsCase expr ms src_loc)
291 = pushSrcLocRn src_loc $
292 rnExpr expr `thenRn` \ (new_expr, e_fvs) ->
293 mapAndUnzipRn rnMatch ms `thenRn` \ (new_ms, ms_fvs) ->
294 returnRn (HsCase new_expr new_ms src_loc, unionManyNameSets (e_fvs : ms_fvs))
296 rnExpr (HsLet binds expr)
297 = rnBinds binds $ \ binds' ->
298 rnExpr expr `thenRn` \ (expr',fvExpr) ->
299 returnRn (HsLet binds' expr', fvExpr)
301 rnExpr (HsDo do_or_lc stmts src_loc)
302 = pushSrcLocRn src_loc $
303 lookupImplicitOccRn monadZeroClass_RDR `thenRn_` -- Forces Monad to come too
304 rnStmts stmts `thenRn` \ (stmts', fvStmts) ->
305 returnRn (HsDo do_or_lc stmts' src_loc, fvStmts)
307 rnExpr (ExplicitList exps)
308 = addImplicitOccRn listType_name `thenRn_`
309 rnExprs exps `thenRn` \ (exps', fvs) ->
310 returnRn (ExplicitList exps', fvs)
312 rnExpr (ExplicitTuple exps)
313 = addImplicitOccRn (tupleType_name (length exps)) `thenRn_`
314 rnExprs exps `thenRn` \ (exps', fvExps) ->
315 returnRn (ExplicitTuple exps', fvExps)
317 rnExpr (RecordCon (HsVar con) rbinds)
318 = lookupOccRn con `thenRn` \ conname ->
319 rnRbinds "construction" rbinds `thenRn` \ (rbinds', fvRbinds) ->
320 returnRn (RecordCon (HsVar conname) rbinds', fvRbinds)
322 rnExpr (RecordUpd expr rbinds)
323 = rnExpr expr `thenRn` \ (expr', fvExpr) ->
324 rnRbinds "update" rbinds `thenRn` \ (rbinds', fvRbinds) ->
325 returnRn (RecordUpd expr' rbinds', fvExpr `unionNameSets` fvRbinds)
327 rnExpr (ExprWithTySig expr pty)
328 = rnExpr expr `thenRn` \ (expr', fvExpr) ->
329 rnHsType pty `thenRn` \ pty' ->
330 returnRn (ExprWithTySig expr' pty', fvExpr)
332 rnExpr (HsIf p b1 b2 src_loc)
333 = pushSrcLocRn src_loc $
334 rnExpr p `thenRn` \ (p', fvP) ->
335 rnExpr b1 `thenRn` \ (b1', fvB1) ->
336 rnExpr b2 `thenRn` \ (b2', fvB2) ->
337 returnRn (HsIf p' b1' b2' src_loc, unionManyNameSets [fvP, fvB1, fvB2])
339 rnExpr (ArithSeqIn seq)
340 = lookupImplicitOccRn enumClass_RDR `thenRn_`
341 rn_seq seq `thenRn` \ (new_seq, fvs) ->
342 returnRn (ArithSeqIn new_seq, fvs)
345 = rnExpr expr `thenRn` \ (expr', fvExpr) ->
346 returnRn (From expr', fvExpr)
348 rn_seq (FromThen expr1 expr2)
349 = rnExpr expr1 `thenRn` \ (expr1', fvExpr1) ->
350 rnExpr expr2 `thenRn` \ (expr2', fvExpr2) ->
351 returnRn (FromThen expr1' expr2', fvExpr1 `unionNameSets` fvExpr2)
353 rn_seq (FromTo expr1 expr2)
354 = rnExpr expr1 `thenRn` \ (expr1', fvExpr1) ->
355 rnExpr expr2 `thenRn` \ (expr2', fvExpr2) ->
356 returnRn (FromTo expr1' expr2', fvExpr1 `unionNameSets` fvExpr2)
358 rn_seq (FromThenTo expr1 expr2 expr3)
359 = rnExpr expr1 `thenRn` \ (expr1', fvExpr1) ->
360 rnExpr expr2 `thenRn` \ (expr2', fvExpr2) ->
361 rnExpr expr3 `thenRn` \ (expr3', fvExpr3) ->
362 returnRn (FromThenTo expr1' expr2' expr3',
363 unionManyNameSets [fvExpr1, fvExpr2, fvExpr3])
366 %************************************************************************
368 \subsubsection{@Rbinds@s and @Rpats@s: in record expressions}
370 %************************************************************************
374 = mapRn field_dup_err dup_fields `thenRn_`
375 mapAndUnzipRn rn_rbind rbinds `thenRn` \ (rbinds', fvRbind_s) ->
376 returnRn (rbinds', unionManyNameSets fvRbind_s)
378 (_, dup_fields) = removeDups cmp [ f | (f,_,_) <- rbinds ]
380 field_dup_err dups = addErrRn (dupFieldErr str dups)
382 rn_rbind (field, expr, pun)
383 = lookupGlobalOccRn field `thenRn` \ fieldname ->
384 rnExpr expr `thenRn` \ (expr', fvExpr) ->
385 returnRn ((fieldname, expr', pun), fvExpr)
388 = mapRn field_dup_err dup_fields `thenRn_`
391 (_, dup_fields) = removeDups cmp [ f | (f,_,_) <- rpats ]
393 field_dup_err dups = addErrRn (dupFieldErr "pattern" dups)
395 rn_rpat (field, pat, pun)
396 = lookupGlobalOccRn field `thenRn` \ fieldname ->
397 rnPat pat `thenRn` \ pat' ->
398 returnRn (fieldname, pat', pun)
401 %************************************************************************
403 \subsubsection{@Stmt@s: in @do@ expressions}
405 %************************************************************************
407 Note that although some bound vars may appear in the free var set for
408 the first qual, these will eventually be removed by the caller. For
409 example, if we have @[p | r <- s, q <- r, p <- q]@, when doing
410 @[q <- r, p <- q]@, the free var set for @q <- r@ will
411 be @{r}@, and the free var set for the entire Quals will be @{r}@. This
412 @r@ will be removed only when we finally return from examining all the
416 rnStmts :: [RdrNameStmt] -> RnMS s ([RenamedStmt], FreeVars)
418 rnStmts [] = returnRn ([], emptyNameSet)
421 = rnStmt stmt $ \ stmt' ->
422 rnStmts stmts `thenRn` \ (stmts', fv_stmts) ->
423 returnRn (stmt':stmts', fv_stmts)
426 -- rnStmt :: RdrNameStmt -> (RenamedStmt -> RnMS s (a, FreeVars)) -> RnMS s (a, FreeVars)
427 -- Because of mutual recursion the actual type is a bit less general than this [Haskell 1.2]
429 rnStmt (BindStmt pat expr src_loc) thing_inside
430 = pushSrcLocRn src_loc $
431 rnExpr expr `thenRn` \ (expr', fv_expr) ->
432 bindLocalsRn "pattern in do binding" binders $ \ new_binders ->
433 rnPat pat `thenRn` \ pat' ->
435 thing_inside (BindStmt pat' expr' src_loc) `thenRn` \ (result, fvs) ->
436 returnRn (result, fv_expr `unionNameSets` (fvs `minusNameSet` mkNameSet new_binders))
438 binders = collectPatBinders pat
440 rnStmt (ExprStmt expr src_loc) thing_inside
441 = pushSrcLocRn src_loc $
442 rnExpr expr `thenRn` \ (expr', fv_expr) ->
443 thing_inside (ExprStmt expr' src_loc) `thenRn` \ (result, fvs) ->
444 returnRn (result, fv_expr `unionNameSets` fvs)
446 rnStmt (GuardStmt expr src_loc) thing_inside
447 = pushSrcLocRn src_loc $
448 rnExpr expr `thenRn` \ (expr', fv_expr) ->
449 thing_inside (GuardStmt expr' src_loc) `thenRn` \ (result, fvs) ->
450 returnRn (result, fv_expr `unionNameSets` fvs)
452 rnStmt (ReturnStmt expr) thing_inside
453 = rnExpr expr `thenRn` \ (expr', fv_expr) ->
454 thing_inside (ReturnStmt expr') `thenRn` \ (result, fvs) ->
455 returnRn (result, fv_expr `unionNameSets` fvs)
457 rnStmt (LetStmt binds) thing_inside
458 = rnBinds binds $ \ binds' ->
459 thing_inside (LetStmt binds')
462 %************************************************************************
464 \subsubsection{Precedence Parsing}
466 %************************************************************************
468 @mkOpAppRn@ deals with operator fixities. The argument expressions
469 are assumed to be already correctly arranged. It needs the fixities
470 recorded in the OpApp nodes, because fixity info applies to the things
471 the programmer actually wrote, so you can't find it out from the Name.
473 Furthermore, the second argument is guaranteed not to be another
474 operator application. Why? Because the parser parses all
475 operator appications left-associatively.
478 mkOpAppRn :: RenamedHsExpr -> RenamedHsExpr -> Fixity -> RenamedHsExpr
479 -> RnMS s RenamedHsExpr
481 mkOpAppRn e1@(OpApp e11 op1 fix1 e12)
484 = addErrRn (precParseErr (get op1,fix1) (get op2,fix2)) `thenRn_`
485 returnRn (OpApp e1 op2 fix2 e2)
488 = mkOpAppRn e12 op2 fix2 e2 `thenRn` \ new_e ->
489 returnRn (OpApp e11 op1 fix1 new_e)
491 (nofix_error, rearrange_me) = compareFixity fix1 fix2
494 mkOpAppRn e1@(NegApp neg_arg neg_id)
496 fix2@(Fixity prec2 dir2)
498 | prec2 > 6 -- Precedence of unary - is wired in as 6!
499 = mkOpAppRn neg_arg op2 fix2 e2 `thenRn` \ new_e ->
500 returnRn (NegApp new_e neg_id)
502 mkOpAppRn e1 op fix e2 -- Default case, no rearrangment
503 = ASSERT( right_op_ok fix e2 )
504 returnRn (OpApp e1 op fix e2)
506 -- Parser left-associates everything, but
507 -- derived instances may have correctly-associated things to
508 -- in the right operarand. So we just check that the right operand is OK
509 right_op_ok fix1 (OpApp _ _ fix2 _)
510 = not error_please && associate_right
512 (error_please, associate_right) = compareFixity fix1 fix2
513 right_op_ok fix1 other
516 -- Parser initially makes negation bind more tightly than any other operator
517 mkNegAppRn mode neg_arg neg_id
518 = ASSERT( not_op_app mode neg_arg )
519 returnRn (NegApp neg_arg neg_id)
521 not_op_app SourceMode (OpApp _ _ _ _) = False
522 not_op_app mode other = True
526 mkConOpPatRn :: RenamedPat -> Name -> Fixity -> RenamedPat
529 mkConOpPatRn p1@(ConOpPatIn p11 op1 fix1 p12)
532 = addErrRn (precParseErr (op1,fix1) (op2,fix2)) `thenRn_`
533 returnRn (ConOpPatIn p1 op2 fix2 p2)
536 = mkConOpPatRn p12 op2 fix2 p2 `thenRn` \ new_p ->
537 returnRn (ConOpPatIn p11 op1 fix1 new_p)
540 (nofix_error, rearrange_me) = compareFixity fix1 fix2
542 mkConOpPatRn p1@(NegPatIn neg_arg)
544 fix2@(Fixity prec2 dir2)
546 | prec2 > 6 -- Precedence of unary - is wired in as 6!
547 = addErrRn (precParseNegPatErr (op2,fix2)) `thenRn_`
548 returnRn (ConOpPatIn p1 op2 fix2 p2)
550 mkConOpPatRn p1 op fix p2 -- Default case, no rearrangment
551 = ASSERT( not_op_pat p2 )
552 returnRn (ConOpPatIn p1 op fix p2)
554 not_op_pat (ConOpPatIn _ _ _ _) = False
555 not_op_pat other = True
559 checkPrecMatch :: Bool -> RdrName -> RdrNameMatch -> RnMS s ()
561 checkPrecMatch False fn match
563 checkPrecMatch True op (PatMatch p1 (PatMatch p2 (GRHSMatch _)))
564 = checkPrec op p1 False `thenRn_`
566 checkPrecMatch True op _
567 = panic "checkPrecMatch"
569 checkPrec op (ConOpPatIn _ op1 _ _) right
570 = lookupFixity op `thenRn` \ op_fix@(Fixity op_prec op_dir) ->
571 lookupFixity op1 `thenRn` \ op1_fix@(Fixity op1_prec op1_dir) ->
573 inf_ok = op1_prec > op_prec ||
574 (op1_prec == op_prec &&
575 (op1_dir == InfixR && op_dir == InfixR && right ||
576 op1_dir == InfixL && op_dir == InfixL && not right))
579 info1 = (op1,op1_fix)
580 (infol, infor) = if right then (info, info1) else (info1, info)
582 checkRn inf_ok (precParseErr infol infor)
584 checkPrec op (NegPatIn _) right
585 = lookupFixity op `thenRn` \ op_fix@(Fixity op_prec op_dir) ->
586 checkRn (op_prec <= 6) (precParseNegPatErr (op,op_fix))
588 checkPrec op pat right
595 (compareFixity op1 op2) tells which way to arrange appication, or
596 whether there's an error.
599 compareFixity :: Fixity -> Fixity
600 -> (Bool, -- Error please
601 Bool) -- Associate to the right: a op1 (b op2 c)
602 compareFixity (Fixity prec1 dir1) (Fixity prec2 dir2)
603 = case prec1 `cmp` prec2 of
606 EQ_ -> case (dir1, dir2) of
607 (InfixR, InfixR) -> right
608 (InfixL, InfixL) -> left
611 right = (False, True)
612 left = (False, False)
613 error_please = (True, False)
616 %************************************************************************
618 \subsubsection{Literals}
620 %************************************************************************
622 When literals occur we have to make sure that the types and classes they involve
626 litOccurrence (HsChar _)
627 = addImplicitOccRn charType_name
629 litOccurrence (HsCharPrim _)
630 = addImplicitOccRn (getName charPrimTyCon)
632 litOccurrence (HsString _)
633 = addImplicitOccRn listType_name `thenRn_`
634 addImplicitOccRn charType_name
636 litOccurrence (HsStringPrim _)
637 = addImplicitOccRn (getName addrPrimTyCon)
639 litOccurrence (HsInt _)
640 = lookupImplicitOccRn numClass_RDR -- Int and Integer are forced in by Num
642 litOccurrence (HsFrac _)
643 = lookupImplicitOccRn fractionalClass_RDR -- ... similarly Rational
645 litOccurrence (HsIntPrim _)
646 = addImplicitOccRn (getName intPrimTyCon)
648 litOccurrence (HsFloatPrim _)
649 = addImplicitOccRn (getName floatPrimTyCon)
651 litOccurrence (HsDoublePrim _)
652 = addImplicitOccRn (getName doublePrimTyCon)
654 litOccurrence (HsLitLit _)
655 = lookupImplicitOccRn ccallableClass_RDR
659 %************************************************************************
661 \subsubsection{Errors}
663 %************************************************************************
666 dupFieldErr str (dup:rest) sty
667 = ppBesides [ppPStr SLIT("duplicate field name `"),
669 ppPStr SLIT("' in record "), ppStr str]
672 = ppSep [ppPStr SLIT("prefix `-' not applied to literal in pattern"), ppr sty pat]
674 precParseNegPatErr op sty
675 = ppHang (ppPStr SLIT("precedence parsing error"))
676 4 (ppBesides [ppPStr SLIT("prefix `-' has lower precedence than "),
678 ppPStr SLIT(" in pattern")])
680 precParseErr op1 op2 sty
681 = ppHang (ppPStr SLIT("precedence parsing error"))
682 4 (ppBesides [ppPStr SLIT("cannot mix "), pp_op sty op1, ppPStr SLIT(" and "), pp_op sty op2,
683 ppPStr SLIT(" in the same infix expression")])
685 pp_op sty (op, fix) = ppBesides [pprSym sty op, ppLparen, ppr sty fix, ppRparen]