FIX #1650: ".boot modules interact badly with the ghci debugger"
[ghc-hetmet.git] / compiler / iface / TcIface.lhs
index 53a9a59..9345208 100644 (file)
@@ -6,10 +6,17 @@
 Type checking of type signatures in interface files
 
 \begin{code}
+{-# OPTIONS -w #-}
+-- The above warning supression flag is a temporary kludge.
+-- While working on this module you are encouraged to remove it and fix
+-- any warnings in the module. See
+--     http://hackage.haskell.org/trac/ghc/wiki/Commentary/CodingStyle#Warnings
+-- for details
+
 module TcIface ( 
        tcImportDecl, checkWiredInTyCon, tcHiBootIface, typecheckIface, 
-       tcIfaceDecl, tcIfaceInst, tcIfaceFamInst, tcIfaceRules, tcIfaceGlobal, 
-       tcExtCoreBindings
+       tcIfaceDecl, tcIfaceInst, tcIfaceFamInst, tcIfaceRules,
+       tcIfaceVectInfo, tcIfaceGlobal, tcExtCoreBindings
  ) where
 
 #include "HsVersions.h"
@@ -38,6 +45,7 @@ import DataCon
 import TysWiredIn
 import Var              ( TyVar )
 import qualified Var
+import VarEnv
 import Name
 import NameEnv
 import OccName
@@ -48,7 +56,6 @@ import Outputable
 import ErrUtils
 import Maybes
 import SrcLoc
-import Util
 import DynFlags
 import Control.Monad
 
@@ -105,6 +112,7 @@ tcImportDecl :: Name -> TcM TyThing
 tcImportDecl name 
   | Just thing <- wiredInNameTyThing_maybe name
   = do { initIfaceTcRn (loadWiredInHomeIface name) 
+               -- See Note [Loading instances] in LoadIface
        ; return thing }
   | otherwise
   = do         { traceIf (text "tcImportDecl" <+> ppr name)
@@ -115,7 +123,8 @@ tcImportDecl name
 
 checkWiredInTyCon :: TyCon -> TcM ()
 -- Ensure that the home module of the TyCon (and hence its instances)
--- are loaded. It might not be a wired-in tycon (see the calls in TcUnify),
+-- are loaded. See See Note [Loading instances] in LoadIface
+-- It might not be a wired-in tycon (see the calls in TcUnify),
 -- in which case this is a no-op.
 checkWiredInTyCon tc   
   | not (isWiredInName tc_name) 
@@ -199,6 +208,10 @@ typecheckIface iface
        ; fam_insts <- mapM tcIfaceFamInst (mi_fam_insts iface)
        ; rules     <- tcIfaceRules ignore_prags (mi_rules iface)
 
+                -- Vectorisation information
+        ; vect_info <- tcIfaceVectInfo (mi_module iface) type_env 
+                                       (mi_vect_info iface)
+
                -- Exports
        ; exports <- ifaceExportNames (mi_exports iface)
 
@@ -209,7 +222,8 @@ typecheckIface iface
                              , md_insts     = insts
                              , md_fam_insts = fam_insts
                              , md_rules     = rules
-                             , md_exports   = exports 
+                              , md_vect_info = vect_info
+                             , md_exports   = exports
                              }
     }
 \end{code}
@@ -222,11 +236,14 @@ typecheckIface iface
 %************************************************************************
 
 \begin{code}
-tcHiBootIface :: Module -> TcRn ModDetails
+tcHiBootIface :: HscSource -> Module -> TcRn ModDetails
 -- Load the hi-boot iface for the module being compiled,
 -- if it indeed exists in the transitive closure of imports
 -- Return the ModDetails, empty if no hi-boot iface
-tcHiBootIface mod
+tcHiBootIface hsc_src mod
+  | isHsBoot hsc_src           -- Already compiling a hs-boot file
+  = return emptyModDetails
+  | otherwise
   = do         { traceIf (text "loadHiBootInterface" <+> ppr mod)
 
        ; mode <- getGhcMode
@@ -374,13 +391,22 @@ tcIfaceDecl ignore_prags
 
 tcIfaceDecl ignore_prags 
            (IfaceSyn {ifName = occ_name, ifTyVars = tv_bndrs, 
-                      ifOpenSyn = isOpen, ifSynRhs = rdr_rhs_ty})
+                      ifOpenSyn = isOpen, ifSynRhs = rdr_rhs_ty,
+                      ifFamInst = mb_family})
    = bindIfaceTyVars tv_bndrs $ \ tyvars -> do
      { tc_name <- lookupIfaceTop occ_name
      ; rhs_tyki <- tcIfaceType rdr_rhs_ty
-     ; let rhs = if isOpen then OpenSynTyCon rhs_tyki 
+     ; let rhs = if isOpen then OpenSynTyCon rhs_tyki Nothing
                           else SynonymTyCon rhs_tyki
-     ; return (ATyCon (buildSynTyCon tc_name tyvars rhs))
+     ; famInst <- case mb_family of
+                   Nothing         -> return Nothing
+                   Just (fam, tys) -> 
+                     do { famTyCon <- tcIfaceTyCon fam
+                        ; insttys <- mapM tcIfaceType tys
+                        ; return $ Just (famTyCon, insttys)
+                        }
+     ; tycon <- buildSynTyCon tc_name tyvars rhs famInst
+     ; return $ ATyCon tycon
      }
 
 tcIfaceDecl ignore_prags
@@ -404,8 +430,8 @@ tcIfaceDecl ignore_prags
      = do { op_name <- lookupIfaceTop occ
          ; op_ty   <- forkM (mk_doc op_name rdr_ty) (tcIfaceType rdr_ty)
                -- Must be done lazily for just the same reason as the 
-               -- context of a data decl: the type sig might mention the
-               -- class being defined
+               -- type of a data con; to avoid sucking in types that
+               -- it mentions unless it's necessray to do so
          ; return (op_name, dm, op_ty) }
 
    mk_doc op_name op_ty = ptext SLIT("Class op") <+> sep [ppr op_name, ppr op_ty]
@@ -436,7 +462,6 @@ tcIfaceDataCons tycon_name tycon tc_tyvars if_cons
   = case if_cons of
        IfAbstractTyCon  -> return mkAbstractTyConRhs
        IfOpenDataTyCon  -> return mkOpenDataTyConRhs
-       IfOpenNewTyCon   -> return mkOpenNewTyConRhs
        IfDataTyCon cons -> do  { data_cons <- mappM tc_con_decl cons
                                ; return (mkDataTyConRhs data_cons) }
        IfNewTyCon con   -> do  { data_con <- tc_con_decl con
@@ -447,8 +472,8 @@ tcIfaceDataCons tycon_name tycon tc_tyvars if_cons
                         ifConOcc = occ, ifConCtxt = ctxt, ifConEqSpec = spec,
                         ifConArgTys = args, ifConFields = field_lbls,
                         ifConStricts = stricts})
-      = bindIfaceTyVars univ_tvs $ \ univ_tyvars -> do
-       bindIfaceTyVars ex_tvs   $ \ ex_tyvars -> do
+     = bindIfaceTyVars univ_tvs $ \ univ_tyvars -> do
+       bindIfaceTyVars ex_tvs   $ \ ex_tyvars -> do
        { name  <- lookupIfaceTop occ
         ; eq_spec <- tcIfaceEqSpec spec
        ; theta <- tcIfaceCtxt ctxt     -- Laziness seems not worth the bother here
@@ -480,7 +505,7 @@ tcIfaceEqSpec spec
     do_item (occ, if_ty) = do { tv <- tcIfaceTyVar (occNameFS occ)
                               ; ty <- tcIfaceType if_ty
                               ; return (tv,ty) }
-\end{code}     
+\end{code}
 
 
 %************************************************************************
@@ -497,7 +522,7 @@ tcIfaceInst (IfaceInst { ifDFun = dfun_occ, ifOFlag = oflag,
   = do { dfun    <- forkM (ptext SLIT("Dict fun") <+> ppr dfun_occ) $
                     tcIfaceExtId dfun_occ
         ; let mb_tcs' = map (fmap ifaceTyConName) mb_tcs
-       ; return (mkImportedInstance cls mb_tcs' orph dfun oflag) }
+       ; return (mkImportedInstance cls mb_tcs' dfun oflag) }
 
 tcIfaceFamInst :: IfaceFamInst -> IfL FamInst
 tcIfaceFamInst (IfaceFamInst { ifFamInstTyCon = tycon, 
@@ -541,13 +566,13 @@ tcIfaceRule (IfaceRule {ifRuleName = name, ifActivation = act, ifRuleBndrs = bnd
                   ; rhs'  <- tcIfaceExpr rhs
                   ; return (bndrs', args', rhs') }
        ; let mb_tcs = map ifTopFreeName args
-        ; lcl <- getLclEnv
-        ; let this_module = if_mod lcl
        ; returnM (Rule { ru_name = name, ru_fn = fn, ru_act = act, 
                          ru_bndrs = bndrs', ru_args = args', 
-                         ru_rhs = rhs', ru_orph = orph,
+                         ru_rhs = rhs', 
                          ru_rough = mb_tcs,
-                         ru_local = nameModule fn == this_module }) }
+                         ru_local = False }) } -- An imported RULE is never for a local Id
+                                               -- or, even if it is (module loop, perhaps)
+                                               -- we'll just leave it in the non-local set
   where
        -- This function *must* mirror exactly what Rules.topFreeName does
        -- We could have stored the ru_rough field in the iface file
@@ -566,6 +591,95 @@ tcIfaceRule (IfaceRule {ifRuleName = name, ifActivation = act, ifRuleBndrs = bnd
 
 %************************************************************************
 %*                                                                     *
+               Vectorisation information
+%*                                                                     *
+%************************************************************************
+
+\begin{code}
+tcIfaceVectInfo :: Module -> TypeEnv  -> IfaceVectInfo -> IfL VectInfo
+tcIfaceVectInfo mod typeEnv (IfaceVectInfo 
+                             { ifaceVectInfoVar        = vars
+                             , ifaceVectInfoTyCon      = tycons
+                             , ifaceVectInfoTyConReuse = tyconsReuse
+                             })
+  = do { vVars     <- mapM vectVarMapping vars
+       ; tyConRes1 <- mapM vectTyConMapping      tycons
+       ; tyConRes2 <- mapM vectTyConReuseMapping tycons
+       ; let (vTyCons, vDataCons, vPAs, vIsos) = unzip4 (tyConRes1 ++ tyConRes2)
+       ; return $ VectInfo 
+                  { vectInfoVar     = mkVarEnv  vVars
+                  , vectInfoTyCon   = mkNameEnv vTyCons
+                  , vectInfoDataCon = mkNameEnv (concat vDataCons)
+                  , vectInfoPADFun  = mkNameEnv vPAs
+                  , vectInfoIso     = mkNameEnv vIsos
+                  }
+       }
+  where
+    vectVarMapping name 
+      = do { vName <- lookupOrig mod (mkVectOcc (nameOccName name))
+           ; let { var  = lookupVar name
+                 ; vVar = lookupVar vName
+                 }
+           ; return (var, (var, vVar))
+           }
+    vectTyConMapping name 
+      = do { vName   <- lookupOrig mod (mkVectTyConOcc (nameOccName name))
+           ; paName  <- lookupOrig mod (mkPADFunOcc    (nameOccName name))
+           ; isoName <- lookupOrig mod (mkVectIsoOcc   (nameOccName name))
+           ; let { tycon    = lookupTyCon name
+                 ; vTycon   = lookupTyCon vName
+                 ; paTycon  = lookupVar paName
+                 ; isoTycon = lookupVar isoName
+                 }
+           ; vDataCons <- mapM vectDataConMapping (tyConDataCons tycon)
+           ; return ((name, (tycon, vTycon)),    -- (T, T_v)
+                     vDataCons,                  -- list of (Ci, Ci_v)
+                     (vName, (vTycon, paTycon)), -- (T_v, paT)
+                     (name, (tycon, isoTycon)))  -- (T, isoT)
+           }
+    vectTyConReuseMapping name 
+      = do { paName  <- lookupOrig mod (mkPADFunOcc    (nameOccName name))
+           ; isoName <- lookupOrig mod (mkVectIsoOcc   (nameOccName name))
+           ; let { tycon      = lookupTyCon name
+                 ; paTycon    = lookupVar paName
+                 ; isoTycon   = lookupVar isoName
+                 ; vDataCons  = [ (dataConName dc, (dc, dc)) 
+                                | dc <- tyConDataCons tycon]
+                 }
+           ; return ((name, (tycon, tycon)),     -- (T, T)
+                     vDataCons,                  -- list of (Ci, Ci)
+                     (name, (tycon, paTycon)),   -- (T, paT)
+                     (name, (tycon, isoTycon)))  -- (T, isoT)
+           }
+    vectDataConMapping datacon
+      = do { let name = dataConName datacon
+           ; vName <- lookupOrig mod (mkVectDataConOcc (nameOccName name))
+           ; let vDataCon = lookupDataCon vName
+           ; return (name, (datacon, vDataCon))
+           }
+    --
+    lookupVar name = case lookupTypeEnv typeEnv name of
+                       Just (AnId var) -> var
+                       Just _         -> 
+                         panic "TcIface.tcIfaceVectInfo: not an id"
+                       Nothing        ->
+                         panic "TcIface.tcIfaceVectInfo: unknown name"
+    lookupTyCon name = case lookupTypeEnv typeEnv name of
+                         Just (ATyCon tc) -> tc
+                         Just _         -> 
+                           panic "TcIface.tcIfaceVectInfo: not a tycon"
+                         Nothing        ->
+                           panic "TcIface.tcIfaceVectInfo: unknown name"
+    lookupDataCon name = case lookupTypeEnv typeEnv name of
+                           Just (ADataCon dc) -> dc
+                           Just _         -> 
+                             panic "TcIface.tcIfaceVectInfo: not a datacon"
+                           Nothing        ->
+                             panic "TcIface.tcIfaceVectInfo: unknown name"
+\end{code}
+
+%************************************************************************
+%*                                                                     *
                        Types
 %*                                                                     *
 %************************************************************************
@@ -609,6 +723,10 @@ tcIfaceExpr (IfaceLcl name)
   = tcIfaceLclId name  `thenM` \ id ->
     returnM (Var id)
 
+tcIfaceExpr (IfaceTick modName tickNo)
+  = tcIfaceTick modName tickNo `thenM` \ id ->
+    returnM (Var id)
+
 tcIfaceExpr (IfaceExt gbl)
   = tcIfaceExtId gbl   `thenM` \ id ->
     returnM (Var id)
@@ -657,21 +775,22 @@ tcIfaceExpr (IfaceCase scrut case_bndr ty alts)
                --     corresponds to the datacon in this case alternative
     in
     extendIfaceIdEnv [case_bndr']      $
-    mappM (tcIfaceAlt tc_app) alts     `thenM` \ alts' ->
-    tcIfaceType ty             `thenM` \ ty' ->
+    mappM (tcIfaceAlt scrut' tc_app) alts      `thenM` \ alts' ->
+    tcIfaceType ty                             `thenM` \ ty' ->
     returnM (Case scrut' case_bndr' ty' alts')
 
 tcIfaceExpr (IfaceLet (IfaceNonRec bndr rhs) body)
-  = tcIfaceExpr rhs            `thenM` \ rhs' ->
-    bindIfaceId bndr           $ \ bndr' ->
-    tcIfaceExpr body           `thenM` \ body' ->
-    returnM (Let (NonRec bndr' rhs') body')
+  = do { rhs' <- tcIfaceExpr rhs
+       ; id   <- tcIfaceLetBndr bndr
+       ; body' <- extendIfaceIdEnv [id] (tcIfaceExpr body)
+       ; return (Let (NonRec id rhs') body') }
 
 tcIfaceExpr (IfaceLet (IfaceRec pairs) body)
-  = bindIfaceIds bndrs         $ \ bndrs' ->
-    mappM tcIfaceExpr rhss     `thenM` \ rhss' ->
-    tcIfaceExpr body           `thenM` \ body' ->
-    returnM (Let (Rec (bndrs' `zip` rhss')) body')
+  = do { ids <- mapM tcIfaceLetBndr bndrs
+       ; extendIfaceIdEnv ids $ do
+       { rhss' <- mapM tcIfaceExpr rhss
+       ; body' <- tcIfaceExpr body
+       ; return (Let (Rec (ids `zip` rhss')) body') } }
   where
     (bndrs, rhss) = unzip pairs
 
@@ -688,12 +807,12 @@ tcIfaceExpr (IfaceNote note expr)
        IfaceCoreNote n   -> returnM (Note (CoreNote n) expr')
 
 -------------------------
-tcIfaceAlt _ (IfaceDefault, names, rhs)
+tcIfaceAlt _ _ (IfaceDefault, names, rhs)
   = ASSERT( null names )
     tcIfaceExpr rhs            `thenM` \ rhs' ->
     returnM (DEFAULT, [], rhs')
   
-tcIfaceAlt _ (IfaceLitAlt lit, names, rhs)
+tcIfaceAlt _ _ (IfaceLitAlt lit, names, rhs)
   = ASSERT( null names )
     tcIfaceExpr rhs            `thenM` \ rhs' ->
     returnM (LitAlt lit, [], rhs')
@@ -701,13 +820,15 @@ tcIfaceAlt _ (IfaceLitAlt lit, names, rhs)
 -- A case alternative is made quite a bit more complicated
 -- by the fact that we omit type annotations because we can
 -- work them out.  True enough, but its not that easy!
-tcIfaceAlt (tycon, inst_tys) (IfaceDataAlt data_occ, arg_strs, rhs)
+tcIfaceAlt scrut (tycon, inst_tys) (IfaceDataAlt data_occ, arg_strs, rhs)
   = do { con <- tcIfaceDataCon data_occ
-       ; ASSERT2( con `elem` tyConDataCons tycon,
-                  ppr con $$ ppr tycon $$ ppr (tyConDataCons tycon) )
-         tcIfaceDataAlt con inst_tys arg_strs rhs }
+#ifdef DEBUG
+       ; ifM (not (con `elem` tyConDataCons tycon))
+             (failIfM (ppr scrut $$ ppr con $$ ppr tycon $$ ppr (tyConDataCons tycon)))
+#endif
+       ; tcIfaceDataAlt con inst_tys arg_strs rhs }
                  
-tcIfaceAlt (tycon, inst_tys) (IfaceTupleAlt boxity, arg_occs, rhs)
+tcIfaceAlt _ (tycon, inst_tys) (IfaceTupleAlt boxity, arg_occs, rhs)
   = ASSERT( isTupleTyCon tycon )
     do { let [data_con] = tyConDataCons tycon
        ; tcIfaceDataAlt data_con inst_tys arg_occs rhs }
@@ -861,14 +982,8 @@ tcIfaceGlobal name
        -- Wired-in things include TyCons, DataCons, and Ids
   = do { ifCheckWiredInThing name; return thing }
   | otherwise
-  = do { (eps,hpt) <- getEpsAndHpt
-       ; dflags <- getDOpts
-       ; case lookupType dflags hpt (eps_PTE eps) name of {
-           Just thing -> return thing ;
-           Nothing    -> do
-
-       { env <- getGblEnv
-       ; case if_rec_types env of {
+  = do { env <- getGblEnv
+       ; case if_rec_types env of {    -- Note [Tying the knot]
            Just (mod, get_type_env) 
                | nameIsLocalOrFrom mod name
                -> do           -- It's defined in the module being compiled
@@ -880,16 +995,39 @@ tcIfaceGlobal name
 
          ; other -> do
 
+       { (eps,hpt) <- getEpsAndHpt
+       ; dflags <- getDOpts
+       ; case lookupType dflags hpt (eps_PTE eps) name of {
+           Just thing -> return thing ;
+           Nothing    -> do
+
        { mb_thing <- importDecl name   -- It's imported; go get it
        ; case mb_thing of
            Failed err      -> failIfM err
            Succeeded thing -> return thing
     }}}}}
 
+-- Note [Tying the knot]
+-- ~~~~~~~~~~~~~~~~~~~~~
+-- The if_rec_types field is used in two situations:
+--
+-- a) Compiling M.hs, which indiretly imports Foo.hi, which mentions M.T
+--    Then we look up M.T in M's type environment, which is splatted into if_rec_types
+--    after we've built M's type envt.
+--
+-- b) In ghc --make, during the upsweep, we encounter M.hs, whose interface M.hi
+--    is up to date.  So we call typecheckIface on M.hi.  This splats M.T into 
+--    if_rec_types so that the (lazily typechecked) decls see all the other decls
+--
+-- In case (b) it's important to do the if_rec_types check *before* looking in the HPT
+-- Because if M.hs also has M.hs-boot, M.T will *already be* in the HPT, but in its
+-- emasculated form (e.g. lacking data constructors).
+
 ifCheckWiredInThing :: Name -> IfL ()
 -- Even though we are in an interface file, we want to make
 -- sure the instances of a wired-in thing are loaded (imagine f :: Double -> Double)
 -- Ditto want to ensure that RULES are loaded too
+-- See Note [Loading instances] in LoadIface
 ifCheckWiredInThing name 
   = do { mod <- getIfModule
                -- Check whether we are typechecking the interface for this
@@ -956,8 +1094,11 @@ tcIfaceExtId name = do { thing <- tcIfaceGlobal name
 
 \begin{code}
 bindIfaceBndr :: IfaceBndr -> (CoreBndr -> IfL a) -> IfL a
-bindIfaceBndr (IfaceIdBndr bndr) thing_inside
-  = bindIfaceId bndr thing_inside
+bindIfaceBndr (IfaceIdBndr (fs, ty)) thing_inside
+  = do { name <- newIfaceName (mkVarOccFS fs)
+       ; ty' <- tcIfaceType ty
+       ; let id = mkLocalId name ty'
+       ; extendIfaceIdEnv [id] (thing_inside id) }
 bindIfaceBndr (IfaceTvBndr bndr) thing_inside
   = bindIfaceTyVar bndr thing_inside
     
@@ -969,28 +1110,26 @@ bindIfaceBndrs (b:bs) thing_inside
     thing_inside (b':bs')
 
 -----------------------
-bindIfaceId :: IfaceIdBndr -> (Id -> IfL a) -> IfL a
-bindIfaceId (occ, ty) thing_inside
-  = do { name <- newIfaceName (mkVarOccFS occ)
+tcIfaceLetBndr (IfLetBndr fs ty info)
+  = do { name <- newIfaceName (mkVarOccFS fs)
        ; ty' <- tcIfaceType ty
-       ; let { id = mkLocalId name ty' }
-       ; extendIfaceIdEnv [id] (thing_inside id) }
-    
-bindIfaceIds :: [IfaceIdBndr] -> ([Id] -> IfL a) -> IfL a
-bindIfaceIds bndrs thing_inside
-  = do         { names <- newIfaceNames (map mkVarOccFS occs)
-       ; tys' <- mappM tcIfaceType tys
-       ; let { ids = zipWithEqual "tcCoreValBndr" mkLocalId names tys' }
-       ; extendIfaceIdEnv ids (thing_inside ids) }
+       ; case info of
+               NoInfo    -> return (mkLocalId name ty')
+               HasInfo i -> return (mkLocalIdWithInfo name ty' (tc_info i)) } 
   where
-    (occs,tys) = unzip bndrs
-
+       -- Similar to tcIdInfo, but much simpler
+    tc_info [] = vanillaIdInfo
+    tc_info (HsInline p     : i) = tc_info i `setInlinePragInfo` p 
+    tc_info (HsArity a      : i) = tc_info i `setArityInfo` a 
+    tc_info (HsStrictness s : i) = tc_info i `setAllStrictnessInfo` Just s 
+    tc_info (other          : i) = pprTrace "tcIfaceLetBndr: discarding unexpected IdInfo" 
+                                           (ppr other) (tc_info i)
 
 -----------------------
-newExtCoreBndr :: IfaceIdBndr -> IfL Id
-newExtCoreBndr (var, ty)
+newExtCoreBndr :: IfaceLetBndr -> IfL Id
+newExtCoreBndr (IfLetBndr var ty _)    -- Ignoring IdInfo for now
   = do { mod <- getIfModule
-       ; name <- newGlobalBinder mod (mkVarOccFS var) noSrcLoc
+       ; name <- newGlobalBinder mod (mkVarOccFS var) noSrcSpan
        ; ty' <- tcIfaceType ty
        ; return (mkLocalId name ty') }
 
@@ -1010,8 +1149,11 @@ bindIfaceTyVars bndrs thing_inside
     (occs,kinds) = unzip bndrs
 
 mk_iface_tyvar :: Name -> IfaceKind -> IfL TyVar
-mk_iface_tyvar name ifKind = do { kind <- tcIfaceType ifKind
-                                ; return (Var.mkTyVar name kind)
-                                }
+mk_iface_tyvar name ifKind
+   = do { kind <- tcIfaceType ifKind
+       ; if isCoercionKind kind then 
+               return (Var.mkCoVar name kind)
+         else
+               return (Var.mkTyVar name kind) }
 \end{code}