-- | Evaluate a core Type representing type level int from the tfp
-- library to a real int.
-eval_tfp_int :: Type.Type -> Int
-eval_tfp_int ty =
+eval_tfp_int :: HscTypes.HscEnv -> Type.Type -> Int
+eval_tfp_int env ty =
unsafeRunGhc $ do
+ GHC.setSession env
-- Automatically import modules for any fully qualified identifiers
setDynFlag DynFlags.Opt_ImplicitImportQualified
tfp_to_int :: Type.Type -> TypeSession Int
tfp_to_int ty = do
lens <- getA vsTfpInts
+ hscenv <- getA vsHscEnv
let existing_len = Map.lookup (OrdType ty) lens
case existing_len of
Just len -> return len
Nothing -> do
- let new_len = eval_tfp_int ty
+ let new_len = eval_tfp_int hscenv ty
modA vsTfpInts (Map.insert (OrdType ty) (new_len))
return new_len
\ No newline at end of file