2 % (c) The AQUA Project, Glasgow University, 1993-1995
4 \section[TcDefaults]{Typechecking \tr{default} declarations}
7 #include "HsVersions.h"
9 module TcDefaults ( tcDefaults ) where
13 import HsSyn ( DefaultDecl(..), MonoType,
14 HsExpr, HsLit, ArithSeqInfo, Fake, InPat)
15 import RnHsSyn ( RenamedDefaultDecl(..) )
16 import TcHsSyn ( TcIdOcc )
19 import Inst ( InstOrigin(..) )
20 import TcEnv ( tcLookupClassByKey )
21 import TcMonoType ( tcMonoType )
22 import TcSimplify ( tcSimplifyCheckThetas )
24 import PrelInfo ( intTy, doubleTy, unitTy )
25 import Unique ( numClassKey )
30 tcDefaults :: [RenamedDefaultDecl]
31 -> TcM s [Type] -- defaulting types to heave
32 -- into Tc monad for later use
36 = returnTc [intTy, doubleTy] -- language-specified default `default'
38 tcDefaults [DefaultDecl mono_tys locn]
40 mapTc tcMonoType mono_tys `thenTc` \ tau_tys ->
43 [] -> returnTc [] -- no defaults
46 -- Check that all the types are instances of Num
47 -- We only care about whether it worked or not
49 tcLookupClassByKey numClassKey `thenNF_Tc` \ num ->
50 tcSimplifyCheckThetas DefaultDeclOrigin
51 [ (num, ty) | ty <- tau_tys ] `thenTc` \ _ ->