isPointed,
isFullyEvaluatedTerm,
-- unsafeDeepSeq,
+
+ sigmaType
) where
#include "HsVersions.h"
-- TODO: Improve the offset handling in decode (make it machine dependant)
-----------------------------------
--- Boilerplate Fold code for Term
+-- * Traversals for Terms
-----------------------------------
data TermFold a = TermFold { fTerm :: Type -> DataCon -> HValue -> [a] -> a
-- in the right side reptypes for newtypes as found in the lhs
-- Sadly it doesn't cover all the possibilities. It does not always manage
-- to recover the highest level type. See test print016 for an example
+-- This is used for approximating a unification over types modulo newtypes that recovers
+-- the most concrete, with-newtypes type
congruenceNewtypes :: TcType -> TcType -> TcM TcType
congruenceNewtypes lhs rhs
-- | pprTrace "Congruence" (ppr lhs $$ ppr rhs) False = undefined
}
tidy ty = tidyType (emptyTidyOccEnv, tidyVarEnv ty) ty
tidyVarEnv ty =
+
mkVarEnv$ [ (v, setTyVarName v (tyVarName tv))
| (tv,v) <- zip alphaTyVars vars]
where vars = varSetElems$ tyVarsOfType ty
| Nothing <- mb_ty = runTR hsc_env . go argTypeKind $ hval
| Just ty <- mb_ty = runTR hsc_env $ do
term <- go argTypeKind hval
- ty' <- instScheme ty
+ ty' <- instScheme (sigmaType ty)
addConstraint ty' (fromMaybe (error "by definition")
(termType term))
return term
subTerms = reOrderTerms subTermsP subTermsNP subTtypes
resType <- liftM mkTyVarTy (newVar k)
baseType <- instScheme (dataConRepType dc)
- let myType = mkFunTys (map (fromMaybe undefined . termType)
+ let myType = mkFunTys (map (fromMaybe (error "cvObtainTerm1") . termType)
subTerms)
resType
addConstraint baseType myType
,fSuspension = \ct ty v b -> fmapMMaybe zonkTcType ty >>= \ty ->
return (Suspension ct ty v b)}
+
+-- Is this defined elsewhere?
+-- Find all free tyvars and insert the appropiate ForAll.
+sigmaType ty = mkForAllTys (varSetElems$ tyVarsOfType (dropForAlls ty)) ty
+
{-
Example of Type Reconstruction
--------------------------------