--- | The inverse function. Strip the GHC.Base.Unknowns in the type of the id, they correspond to tyvars. The caller must provide an infinite list of fresh names
-stripUnknowns :: [Name] -> Id -> Id
-stripUnknowns names id = setIdType id . fst . go names . idType
- $ id
- where
- go tyvarsNames@(v:vv) ty
- | Just (ty1,ty2) <- splitFunTy_maybe ty = let
- (ty1',vv') = go tyvarsNames ty1
- (ty2',vv'')= go vv' ty2
- in (mkFunTy ty1' ty2', vv'')
- | Just (ty1,ty2) <- splitAppTy_maybe ty = let
- (ty1',vv') = go tyvarsNames ty1
- (ty2',vv'')= go vv' ty2
- in (mkAppTy ty1' ty2', vv'')
- | Just (tycon, args) <- splitTyConApp_maybe ty
- , Just (tycon', vv') <- (fixTycon tycon tyvarsNames)
- , (args',vv'') <- foldr (\arg (aa,vv) -> let (arg',vv') = go vv' arg
- in (arg':aa,vv'))
- ([],vv') args
- = (mkAppTys tycon' args',vv'')
- | Just (tycon, args) <- splitTyConApp_maybe ty
- , (args',vv') <- foldr (\arg (aa,vv) -> let (arg',vv') = go vv' arg
- in (arg':aa,vv'))
- ([],tyvarsNames) args
- = (mkTyConApp tycon args',vv')
- | otherwise = (ty, tyvarsNames)
- where fixTycon tycon (v:vv) = do
- k <- lookup (tyConName tycon) kinds
- return (mkTyVarTy$ mkTyVar v k, vv)
- kinds = [ (unknownTyConName, liftedTypeKind)
- , (unknown1TyConName, kind1)
- , (unknown2TyConName, kind2)
- , (unknown3TyConName, kind3)]
- kind1 = mkArrowKind liftedTypeKind liftedTypeKind
- kind2 = mkArrowKind kind1 liftedTypeKind
- kind3 = mkArrowKind kind2 liftedTypeKind
-
-instantiateTyVarsToUnknown :: Session -> Type -> IO Type
-instantiateTyVarsToUnknown (Session ref) ty
- = do hsc_env <- readIORef ref
- DebuggerTys.instantiateTyVarsToUnknown hsc_env ty