[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcIfaceSig.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1994
3 %
4 \section[TcIfaceSig]{Type checking of type signatures in interface files}
5
6 \begin{code}
7 #include "HsVersions.h"
8
9 module TcIfaceSig ( tcInterfaceSigs ) where
10
11 IMPORT_Trace            -- ToDo: rm (debugging)
12 import Outputable
13 import Pretty
14
15 import TcMonad          -- typechecking monadic machinery
16 import AbsSyn           -- the stuff being typechecked
17
18 import AbsUniType       ( splitType, splitTyArgs )
19 import CmdLineOpts      ( GlobalSwitch(..) )
20 import E                ( getE_CE, getE_TCE, nullGVE, unitGVE,
21                           plusGVE, GVE(..), E, CE(..), TCE(..), UniqFM
22                         )
23 import Errors           ( confusedNameErr )
24 import Id               -- mkImported
25 #if USE_ATTACK_PRAGMAS
26 import IdInfo           ( workerExists )
27 #endif
28 import Maybes           ( Maybe(..) )
29 import TcPragmas        ( tcGenPragmas )
30 import TVE              ( nullTVE, TVE(..) )
31 import TcPolyType       ( tcPolyType )
32 import UniqFM           ( emptyUFM ) -- profiling, pragmas only
33 import Util
34 \end{code}
35
36 Ultimately, type signatures in interfaces will have pragmatic
37 information attached, so it is a good idea to have separate code to
38 check them.
39
40 As always, we do not have to worry about user-pragmas in interface
41 signatures.
42
43 \begin{code}
44 tcInterfaceSigs :: E -> [RenamedSig] -> Baby_TcM GVE
45
46 tcInterfaceSigs e [] = returnB_Tc nullGVE
47
48 tcInterfaceSigs e (sig:sigs)
49   = tc_sig            sig  `thenB_Tc` \ gve1 ->
50     tcInterfaceSigs e sigs `thenB_Tc` \ gve2 ->
51     returnB_Tc (plusGVE gve1 gve2)
52   where
53     ce  = getE_CE  e
54     tce = getE_TCE e
55
56     tc_sig (Sig name@(OtherTopId uniq full_name) ty pragmas src_loc)
57       = addSrcLocB_Tc src_loc                    (
58         tcPolyType ce tce nullTVE ty    `thenB_Tc` \ sigma_ty ->
59
60         fixB_Tc ( \ rec_imported_id ->
61             tcGenPragmas e (Just sigma_ty) rec_imported_id pragmas
62                                 `thenB_Tc` \ id_info ->
63
64             returnB_Tc (mkImported uniq full_name sigma_ty id_info)
65         ) `thenB_Tc` \ final_id ->
66
67         returnB_Tc (unitGVE name final_id)
68         )
69
70     tc_sig (Sig odd_name _ _ src_loc)
71       = getSwitchCheckerB_Tc    `thenB_Tc` \ sw_chkr ->
72         case odd_name of
73           WiredInVal _ | sw_chkr CompilingPrelude -- OK, that's cool; ignore
74             -> returnB_Tc nullGVE
75           _ -> failB_Tc (confusedNameErr "Bad name on a type signature (a Prelude name?)"
76                                 odd_name src_loc)
77 \end{code}