f9e79c8c6e45eeb61a44302780c8fcabff446312
[ghc-hetmet.git] / ghc / compiler / typecheck / Typecheck.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
3 %
4 \section[Typecheck]{Outside-world interfaces to the typechecker}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module Typecheck (
10         typecheckModule, InstInfo
11     ) where
12
13 import Ubiq
14 import TcMonad
15 import TcModule         ( tcModule )
16 import TcInstUtil       ( InstInfo )
17
18 import HsSyn
19 import RnHsSyn
20 import TcHsSyn
21
22 import ErrUtils         ( Warning(..), Error(..) )
23 import Pretty
24 import RnUtils          ( RnEnv(..) )
25 import Maybes           ( MaybeErr(..) )
26 \end{code}
27
28 The typechecker stuff lives inside a complicated world of @TcM@
29 monadery. 
30
31 ToDo: Interfaces for interpreter ...
32         Typecheck an expression
33         Typecheck an interface
34
35 \begin{code}
36 typecheckModule
37     :: UniqSupply               -- name supply in
38     -> RnEnv                    -- renamer env (for doing derivings)
39     -> RenamedHsModule          -- input module
40
41     -> -- OUTPUTS ...
42     MaybeErr
43        -- SUCCESS ...
44       (((TypecheckedHsBinds,       -- record selector definitions
45          TypecheckedHsBinds,       -- binds from class decls; does NOT
46                                    --    include default-methods bindings
47          TypecheckedHsBinds,       -- binds from instance decls; INCLUDES
48                                    --    class default-methods binds
49          TypecheckedHsBinds,       -- binds from value decls
50
51          [(Id, TypecheckedHsExpr)] -- constant instance binds
52         ),
53
54         ([RenamedFixityDecl], [Id], [TyCon], [Class], Bag InstInfo),
55                                 -- things for the interface generator
56
57         ([TyCon], [Class]),
58                                 -- environments of info from this module only
59
60         FiniteMap TyCon [(Bool, [Maybe Type])],
61                                 -- source tycon specialisation requests
62
63         PprStyle->Pretty),      -- stuff to print for -ddump-deriving
64
65        Bag Warning)             -- pretty-print this to get warnings
66
67        -- FAILURE ...
68       (Bag Error,               -- pretty-print this to get errors
69        Bag Warning)             -- pretty-print this to get warnings
70
71 typecheckModule us rn_env mod
72   = initTc us (tcModule rn_env mod)
73 \end{code}