From d6539020282e1f435a8b00aba0f6362141066899 Mon Sep 17 00:00:00 2001 From: darkf Date: Tue, 29 Oct 2013 02:49:02 -0700 Subject: [PATCH] Use module scope for global scope in in module-prefixed functions --- interp.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/interp.hs b/interp.hs index 6ed6cdb..b50e17f 100644 --- a/interp.hs +++ b/interp.hs @@ -290,9 +290,14 @@ eval (Access left (Var right)) = do case lhs of DictV dict -> case M.lookup (StrV right) dict of + Just (FnV [] fn) -> -- use the module's global scope + return $ FnV (mapToEnv dict) fn Just v -> return v Nothing -> return $ TupleV [StrV "nothing"] _ -> error $ "op/: need a dict, got " ++ show lhs + where + mapToEnv :: M.Map Value Value -> Env + mapToEnv m = [M.fromAscList $ map (\(StrV k,v) -> (k,v)) (M.toAscList m)] eval (Access _ _) = error "op/: RHS must be an identifier" eval (Call lhs arg) = do