[project @ 1996-03-19 08:58:34 by partain]
[ghc-hetmet.git] / ghc / compiler / typecheck / TcIfaceSig.lhs
1 %
2 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1996
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 Ubiq
12
13 import TcMonad
14 import TcMonoType       ( tcPolyType )
15
16 import HsSyn            ( Sig(..), PolyType )
17 import RnHsSyn          ( RenamedSig(..) )
18
19 import CmdLineOpts      ( opt_CompilingPrelude )
20 import Id               ( mkImported )
21 import Name             ( Name(..) )
22 import Pretty
23 import Util             ( panic )
24
25
26 --import TcPragmas      ( tcGenPragmas )
27 import IdInfo           ( noIdInfo )
28 tcGenPragmas ty id ps = returnNF_Tc noIdInfo
29
30 \end{code}
31
32 Ultimately, type signatures in interfaces will have pragmatic
33 information attached, so it is a good idea to have separate code to
34 check them.
35
36 As always, we do not have to worry about user-pragmas in interface
37 signatures.
38
39 \begin{code}
40 tcInterfaceSigs :: [RenamedSig] -> TcM s [Id]
41
42 tcInterfaceSigs [] = returnTc []
43
44 tcInterfaceSigs (Sig name@(ValName uniq full_name) ty pragmas src_loc : sigs)
45   = tcAddSrcLoc src_loc         (
46     tcPolyType ty               `thenTc` \ sigma_ty ->
47     fixTc ( \ rec_id ->
48         tcGenPragmas (Just sigma_ty) rec_id pragmas
49                                 `thenNF_Tc` \ id_info ->
50         returnTc (mkImported uniq full_name sigma_ty id_info)
51     ))                          `thenTc` \ id ->
52     tcInterfaceSigs sigs        `thenTc` \ sigs' ->
53     returnTc (id:sigs')
54
55
56 tcInterfaceSigs (Sig odd_name _ _ src_loc : sigs)
57   = case odd_name of
58       WiredInVal _ | opt_CompilingPrelude
59         -> tcInterfaceSigs sigs
60       _ -> tcAddSrcLoc src_loc  $
61            failTc (ifaceSigNameErr odd_name)
62
63 ifaceSigNameErr name sty
64   = ppHang (ppStr "Bad name in an interface type signature (a Prelude name?)")
65          4 (ppr sty name)
66 \end{code}