2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
4 \section[TcQuals]{TcQuals}
7 #include "HsVersions.h"
9 module TcQuals ( tcQuals ) where
11 import TcMonad -- typechecking monad machinery
12 import AbsSyn -- the stuff being typechecked
14 import AbsPrel ( boolTy, mkListTy )
15 import E ( E, TCE(..), UniqFM, CE(..) )
16 -- TCE and CE for pragmas only
17 import Errors ( UnifyErrContext(..) )
18 import LIE ( LIE, plusLIE )
19 import TcExpr ( tcExpr )
20 import TcPat ( tcPat )
21 import Unify ( unifyTauTy )
25 There will be at least one @Qual@.
28 tcQuals :: E -> [RenamedQual] -> TcM ([TypecheckedQual], LIE)
31 = tcQual e qual `thenTc` \ (new_qual, lie) ->
32 returnTc ([new_qual], lie)
34 tcQuals e (qual:quals)
35 = tcQual e qual `thenTc` \ (new_qual, lie1) ->
36 tcQuals e quals `thenTc` \ (new_quals, lie2) ->
37 returnTc (new_qual : new_quals, lie1 `plusLIE` lie2)
41 tcQual e (FilterQual expr)
42 = tcExpr e expr `thenTc` \ (expr', lie, ty) ->
43 unifyTauTy ty boolTy (FilterCtxt expr) `thenTc_`
44 returnTc (FilterQual expr', lie)
46 tcQual e (GeneratorQual pat expr)
47 = tcPat e pat `thenTc` \ (pat', lie_pat, pat_ty) ->
48 tcExpr e expr `thenTc` \ (expr', lie_expr, expr_ty) ->
50 unifyTauTy expr_ty (mkListTy pat_ty) (GeneratorCtxt pat expr) `thenTc_`
52 returnTc (GeneratorQual pat' expr', lie_pat `plusLIE` lie_expr)