import HsSyn ( TyClDecl(..), HsTupCon(..) )
import TcMonad
-import TcMonoType ( tcHsType )
- -- NB: all the tyars in interface files are kinded,
- -- so tcHsType will do the Right Thing without
- -- having to mess about with zonking
-
+import TcMonoType ( tcIfaceType )
import TcEnv ( TcEnv, RecTcEnv, tcExtendTyVarEnv,
tcExtendGlobalValEnv, tcSetEnv,
tcLookupGlobal_maybe, tcLookupRecId_maybe
do_one name ty id_infos src_loc
= tcAddSrcLoc src_loc $
tcAddErrCtxt (ifaceSigCtxt name) $
- tcHsType ty `thenTc` \ sigma_ty ->
+ tcIfaceType ty `thenTc` \ sigma_ty ->
tcIdInfo unf_env in_scope_vars name
sigma_ty id_infos `thenTc` \ id_info ->
returnTc (mkId name sigma_ty id_info)
tcCoreExpr :: UfExpr Name -> TcM CoreExpr
tcCoreExpr (UfType ty)
- = tcHsType ty `thenTc` \ ty' ->
+ = tcIfaceType ty `thenTc` \ ty' ->
-- It might not be of kind type
returnTc (Type ty')
-- The dreaded lit-lits are also similar, except here the type
-- is read in explicitly rather than being implicit
tcCoreExpr (UfLitLit lit ty)
- = tcHsType ty `thenTc` \ ty' ->
+ = tcIfaceType ty `thenTc` \ ty' ->
returnTc (Lit (MachLitLit lit ty'))
tcCoreExpr (UfCCall cc ty)
- = tcHsType ty `thenTc` \ ty' ->
+ = tcIfaceType ty `thenTc` \ ty' ->
tcGetUnique `thenNF_Tc` \ u ->
returnTc (Var (mkCCallOpId u cc ty'))
tcCoreExpr (UfNote note expr)
= tcCoreExpr expr `thenTc` \ expr' ->
case note of
- UfCoerce to_ty -> tcHsType to_ty `thenTc` \ to_ty' ->
+ UfCoerce to_ty -> tcIfaceType to_ty `thenTc` \ to_ty' ->
returnTc (Note (Coerce to_ty'
(exprType expr')) expr')
UfInlineCall -> returnTc (Note InlineCall expr')
\begin{code}
tcCoreLamBndr (UfValBinder name ty) thing_inside
- = tcHsType ty `thenTc` \ ty' ->
+ = tcIfaceType ty `thenTc` \ ty' ->
let
id = mkVanillaId name ty'
in
thing_inside (b':bs')
tcCoreValBndr (UfValBinder name ty) thing_inside
- = tcHsType ty `thenTc` \ ty' ->
+ = tcIfaceType ty `thenTc` \ ty' ->
let
id = mkVanillaId name ty'
in
thing_inside id
tcCoreValBndrs bndrs thing_inside -- Expect them all to be ValBinders
- = mapTc tcHsType tys `thenTc` \ tys' ->
+ = mapTc tcIfaceType tys `thenTc` \ tys' ->
let
ids = zipWithEqual "tcCoreValBndr" mkVanillaId names tys'
in
tcCoreAlt scrut_ty (UfLitLitAlt str ty, names, rhs)
= ASSERT( null names )
tcCoreExpr rhs `thenTc` \ rhs' ->
- tcHsType ty `thenTc` \ ty' ->
+ tcIfaceType ty `thenTc` \ ty' ->
returnTc (LitAlt (MachLitLit str ty'), [], rhs')
-- A case alternative is made quite a bit more complicated
\section[TcMonoType]{Typechecking user-specified @MonoTypes@}
\begin{code}
-module TcMonoType ( tcHsType, tcHsRecType,
+module TcMonoType ( tcHsType, tcHsRecType, tcIfaceType,
tcHsSigType, tcHsLiftedSigType,
tcRecClassContext, checkAmbiguity,
\begin{code}
tcHsSigType, tcHsLiftedSigType :: RenamedHsType -> TcM Type
-- Do kind checking, and hoist for-alls to the top
-tcHsSigType ty = kcTypeType ty `thenTc_` tcHsType ty
-tcHsLiftedSigType ty = kcLiftedType ty `thenTc_` tcHsType ty
+tcHsSigType ty = kcTypeType ty `thenTc_` tcHsType ty
+tcHsLiftedSigType ty = kcLiftedType ty `thenTc_` tcHsType ty
tcHsType :: RenamedHsType -> TcM Type
tcHsRecType :: RecFlag -> RenamedHsType -> TcM Type
-- Don't do kind checking, but do hoist for-alls to the top
+ -- These are used in type and class decls, where kinding is
+ -- done in advance
tcHsType ty = tc_type NonRecursive ty `thenTc` \ ty' -> returnTc (hoistForAllTys ty')
tcHsRecType wimp_out ty = tc_type wimp_out ty `thenTc` \ ty' -> returnTc (hoistForAllTys ty')
+
+-- In interface files the type is already kinded,
+-- and we definitely don't want to hoist for-alls.
+-- Otherwise we'll change
+-- dmfail :: forall m:(*->*) Monad m => forall a:* => String -> m a
+-- into
+-- dmfail :: forall m:(*->*) a:* Monad m => String -> m a
+-- which definitely isn't right!
+tcIfaceType ty = tc_type NonRecursive ty
\end{code}