import TcTyClsDecls ( tcTyAndClassDecls )
import TcTyDecls ( mkDataBinds )
import TcType ( TcType, typeToTcType,
- TcKind, kindToTcKind
+ TcKind, kindToTcKind,
+ newTyVarTy
)
import RnMonad ( RnNameSupply )
import TyCon ( TyCon, tyConKind )
import DataCon ( dataConId )
import Class ( Class, classSelIds, classTyCon )
-import Type ( mkTyConApp, Type )
+import Type ( mkTyConApp, mkForAllTy, mkTyVarTy,
+ boxedTypeKind, getTyVar, Type )
import TysWiredIn ( unitTy )
import PrelMods ( mAIN )
import PrelInfo ( main_NAME, ioTyCon_NAME,
tcLookupTyCon ioTyCon_NAME `thenTc` \ ioTyCon ->
tcLookupValueMaybe main_NAME `thenNF_Tc` \ maybe_main_id ->
case maybe_main_id of {
- Nothing -> failWithTc noMainErr ;
+ Nothing -> failWithTc noMainErr ;
Just main_id ->
-- Check that it has the right type (or a more general one)
+ -- As of Haskell 98, anything that unifies with (IO a) is OK.
+ newTyVarTy boxedTypeKind `thenNF_Tc` \ t_tv ->
let
- expected_tau = typeToTcType (mkTyConApp ioTyCon [unitTy])
+ tv = getTyVar "tcCheckMainSig" t_tv
+ expected_tau = typeToTcType ((mkTyConApp ioTyCon [t_tv]))
in
tcId main_NAME `thenNF_Tc` \ (_, lie, main_tau) ->
tcSetErrCtxt mainTyCheckCtxt $