module EnvSimple(T, empty_env, lookup_variable, maybe_lookup_variable, bind_variable, variable_table, merge_declarations) where import qualified Table type Symbol = String data T val = Env (Table.T Symbol val) instance Eq val => Eq(T val c) where (Env t1) == (Env t2) = t1 == t2 empty_env :: T val empty_env = Env Table.empty lookup_variable :: T val -> Symbol -> val lookup_variable (Env t) name = Table.lookup t name maybe_lookup_variable :: T val -> Symbol -> Maybe val maybe_lookup_variable (Env t) name = Table.maybe_lookup t name bind_variable :: T val -> Symbol -> val -> T val bind_variable (Env t) name loc = Env (Table.bind t name loc) variable_table :: T val -> Table.T Symbol val variable_table (Env t) = t merge_declarations :: T val -> Table.T Symbol val -> T val merge_declarations (Env t) decls = Env (Table.merge t decls)