Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Lit (LInt _) -> return (nullSubst, typeInt)<br />
Lit (LBool _) -> return (nullSubst, typeBool)<br />
Let’s walk through each of the rule derivations and look how it translates into code:<br />
T-Var<br />
e T-Var rule, simply pull the type of the variable out of the typing context.<br />
Var x -> lookupEnv env x<br />
e function lookupVar looks up the local variable reference in typing environment and if found it<br />
instantiates a fresh copy.<br />
lookupEnv :: TypeEnv -> Var -> Infer (Subst, Type)<br />
lookupEnv (TypeEnv env) x = do<br />
case Map.lookup x env of<br />
Nothing -> throwError $ UnboundVariable (show x)<br />
Just s -> do t do<br />
tv