Interp: don't remove prelude from modules; add patternBindings error
This commit is contained in:
parent
715efff347
commit
7179a6d818
|
@ -233,8 +233,8 @@ _Import (StrV modname) = do
|
||||||
evalFile path -- evaluate the module file
|
evalFile path -- evaluate the module file
|
||||||
[modenv] <- get -- get the module env
|
[modenv] <- get -- get the module env
|
||||||
let [initialEnv] = initialState
|
let [initialEnv] = initialState
|
||||||
let modenv' = M.difference modenv initialEnv -- subtract prelude stuff
|
--let modenv' = M.difference modenv initialEnv -- subtract prelude stuff
|
||||||
let mod = toDict modenv'
|
let mod = toDict modenv
|
||||||
let env' = bind env (T.pack modname) mod -- bind it
|
let env' = bind env (T.pack modname) mod -- bind it
|
||||||
put env' -- restore state
|
put env' -- restore state
|
||||||
return mod -- return module value
|
return mod -- return module value
|
||||||
|
@ -456,6 +456,8 @@ patternBindings (TupleP (x:xs)) (TupleV (y:ys)) =
|
||||||
Just $ M.union env' env
|
Just $ M.union env' env
|
||||||
patternBindings (TupleP _) _ = Nothing -- not a tuple
|
patternBindings (TupleP _) _ = Nothing -- not a tuple
|
||||||
|
|
||||||
|
patternBindings p x = error $ "patternBindings failure: matching " ++ show x ++ " with pattern " ++ show p
|
||||||
|
|
||||||
-- applies a function
|
-- applies a function
|
||||||
apply :: Value -> Value -> InterpState Value
|
apply :: Value -> Value -> InterpState Value
|
||||||
apply (FnV _ pats) arg =
|
apply (FnV _ pats) arg =
|
||||||
|
|
Loading…
Reference in New Issue