[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcQuals.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
3 %
4 \section[TcQuals]{TcQuals}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module TcQuals ( tcQuals ) where
10
11 import TcMonad          -- typechecking monad machinery
12 import AbsSyn           -- the stuff being typechecked
13
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 )
22 import Util
23 \end{code}
24
25 There will be at least one @Qual@.
26
27 \begin{code}
28 tcQuals :: E -> [RenamedQual] -> TcM ([TypecheckedQual], LIE)
29
30 tcQuals e [qual]
31   = tcQual e qual   `thenTc` \ (new_qual, lie) ->
32     returnTc ([new_qual], lie)
33
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)
38
39 ---
40
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)
45
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) ->
49
50     unifyTauTy expr_ty (mkListTy pat_ty) (GeneratorCtxt pat expr) `thenTc_`
51
52     returnTc (GeneratorQual pat' expr', lie_pat `plusLIE` lie_expr)
53 \end{code}
54
55