summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2009-01-15 00:26:12 +0000
committerTim Chevalier <chevalier@alum.wellesley.edu>2009-01-15 00:26:12 +0000
commitee69a45c027e2a9fefd9a97bfd64e78b49d0ecbe (patch)
treeef4b73438e666427ce461a78d2c667f075536a58 /utils
parent5a4c6ef6e909fbd978ff81bb3453489e884d1885 (diff)
downloadhaskell-ee69a45c027e2a9fefd9a97bfd64e78b49d0ecbe.tar.gz
External Core: re-add code I removed mistakenly in last commit
Diffstat (limited to 'utils')
-rw-r--r--utils/ext-core/Language/Core/Check.hs17
-rw-r--r--utils/ext-core/Language/Core/Prep.hs2
2 files changed, 16 insertions, 3 deletions
diff --git a/utils/ext-core/Language/Core/Check.hs b/utils/ext-core/Language/Core/Check.hs
index 9f7a27670d..3ae94e3697 100644
--- a/utils/ext-core/Language/Core/Check.hs
+++ b/utils/ext-core/Language/Core/Check.hs
@@ -5,7 +5,7 @@ module Language.Core.Check(
primCoercionError,
Menv, Venv, Tvenv, Envs(..),
CheckRes(..), splitTy, substl,
- mkTypeEnvsNoChecking) where
+ mkTypeEnvsNoChecking, NtEnv, mkNtEnv) where
--import Debug.Trace
@@ -18,6 +18,7 @@ import Language.Core.Environments
import Control.Monad.Reader
import Data.List
+import qualified Data.Map as M
import Data.Maybe
{- Checking is done in a simple error monad. In addition to
@@ -632,3 +633,17 @@ primCoercionError s = error $ "Bad coercion application: " ++ show s
reportError :: Show a => a -> String -> b
reportError e s = error $ ("Core type error: checkExpr failed with "
++ s ++ " and " ++ show e)
+
+type NtEnv = M.Map Tcon CoercionKind
+
+mkNtEnv :: Menv -> NtEnv
+mkNtEnv menv =
+ foldl M.union M.empty $
+ map (\ (_,e) ->
+ foldr (\ (_,thing) rest ->
+ case thing of
+ Kind _ -> rest
+ Coercion d@(DefinedCoercion _ (lhs,_)) ->
+ case splitTyConApp_maybe lhs of
+ Just ((_,tc1),_) -> M.insert tc1 d rest
+ _ -> rest) M.empty (etolist (tcenv_ e))) (etolist menv)
diff --git a/utils/ext-core/Language/Core/Prep.hs b/utils/ext-core/Language/Core/Prep.hs
index a557b805e5..1ce8fda30e 100644
--- a/utils/ext-core/Language/Core/Prep.hs
+++ b/utils/ext-core/Language/Core/Prep.hs
@@ -224,8 +224,6 @@ newtypeCoercion_maybe ntEnv t | Just ((_,tc),_) <- splitTyConApp_maybe t =
M.lookup tc ntEnv
newtypeCoercion_maybe _ _ = Nothing
-type NtEnv = M.Map Tcon CoercionKind
-
mkTapp :: Ty -> [Ty] -> Ty
mkTapp = foldl Tapp