text stringlengths 0 601k |
|---|
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1 t2) t1' t2'... |
let unused_vars_tests = [ (Let ("x", I 1, I 5), ["x"]) ; (Rec ("f", Arrow ([Int], Int), Fn ([("x", Int)], If (Primop (Equals, [Var "x"; I 0]), I 0, Primop (Plus, [Var "x"; Apply (Var "f", [Primop (Minus, [Var "x"; I 1])])])))), []); (Rec ("f", Arrow ([Int; Int], Int), Fn ([("x", Int); ("y", Int)], If (Primop (Equals, [... |
let subst_tests : (((exp * name) * exp) * exp) list = [ (((I 1, "x"), Let ("y", I 2, Primop (Plus, [Var "y"; Var "x"]))), Let ("y", I 2, Primop (Plus, [Var "y"; I 1]))); (((I 1, "o"), Rec ("o", Arrow ([Int; Bool], Int), Var "o")), (Rec ("o", Arrow ([Int; Bool], Int), Var "o"))); (((I 1, "x"), Rec ("o", Arrow ([Int; Boo... |
let eval_tests = [ (Let ("x", I 1, Primop (Plus, [Var "x"; I 5])), I 6); (Rec ("o", Arrow ([Int; Bool], Int), I 1), I 1); (Apply (ex1, [I 1; I 2]), I 5); (Apply (Rec ("f", Arrow ([Int], Int), Fn ([("x", Int)], If (Primop (Equals, [Var "x"; I 0]), I 0, Primop (Plus, [Var "x"; Apply (Var "f", [Primop (Minus, [Var "x"; I ... |
let infer_tests = [ (([("x", Int)], Var "x"), Int); (([("x", Int)], Rec ("f", Arrow ([Int], Int), Fn ([("x", Int)], If (Primop (Equals, [Var "x"; I 0]), I 0, Primop (Plus, [Var "x"; Apply (Var "f", [Primop (Minus, [Var "x"; I 1])])]))))), Arrow ([Int], Int)); ((empty, Fn ([], I 1)), Arrow ([], Int)); (([("x", Int)], Fn... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unused_vars_tests = [ (Let ("x", I 1, I 5), ["x"]); (Rec ("x", Int, I 5), ["x"]); (Rec ("x", Int, Var "x"), [] ); (Fn ([("x", Int)] , Var "x" ), []); (Fn ([("x", Int)] , Var "y" ), ["x"]); (Fn ([("x", Int); ("y", Int)] , Var "x" ), ["y"]); (Apply (Fn ([("x", Int)], Var "x"), [(I 1)]), []); (Apply (Fn ([("x", Int)],... |
let subst_tests : (((exp * name) * exp) * exp) list = [ (((I 1, "x"), Let ("y", I 2, Primop (Plus, [Var "y"; Var "x"]))), Let ("y", I 2, Primop (Plus, [Var "y"; I 1]))); (((I 1, "x"), Rec ("y", Int, Primop (Plus, [Var "y"; Var "x"]))), Rec("y", Int, Primop (Plus, [Var "y"; I 1]))); (((I 1, "x"), Rec ("x", Int, Primop (... |
let eval_tests = [ (Let ("x", I 1, Primop (Plus, [Var "x"; I 5])), I 6); (Rec ("x", Int, Primop(Plus, [I 1; I 5])), I 6); (Rec ("x", Int, Let ("y", I 1, Primop (Plus, [Var "y"; I 5]))), I 6); (Apply (Fn ([], I 1), []), I 1); (Apply (Fn ([("x", Int)], Var "x"), [(I 1)]), I 1 ); (Apply (Fn ([("x", Int);("y", Int)], Primo... |
let infer_tests = [ (([("x", Int)], Var "x"), Int); (([], Rec("x", Int, Var "x")), Int); (([], ex1), Arrow ([Int; Int], Int)); (([], ex2), Arrow ([], Bool)); (([], Fn([("x", Int)], I 1)), Arrow([Int], Int)); (([], Fn([("x", Int);("y", Int)], I 1)), Arrow([Int; Int], Int)); (([], Apply(Fn ([], I 1),[])), Int); (([], App... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1 t2) t1' t2'... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> if (t1 == t2 && t1' == t2') then substit... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1 t2) t1' t2'... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> if (t1= t1' && t2=t2') then unify substi... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> if (t1= t1' && t2=t2') then unify substi... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1' t2') t1 t2... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1 t2) t1' t2'... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1' t2' ) t1 t... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> let newsub = unify substitution t1 t2 in... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> raise NotImplemented | UTVar a, _ -> uni... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> raise NotImplemented | UTVar a, _ -> uni... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> let m1 = unify substitution t1 t2 in let... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1 t2) t1' t2'... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> substitution | UTVar a, _ -> unifyVar su... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitution t1 t2) t1' t2'... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> let substitution = unify substitution t1... |
let rec unused_vars = function | Var _ | I _ | B _ -> [] | If (e, e1, e2) -> unused_vars e @ unused_vars e1 @ unused_vars e2 | Primop (_, args) -> List.fold_left (fun acc exp -> acc @ unused_vars exp) [] args | Let (x, e1, e2) -> let unused = unused_vars e1 @ unused_vars e2 in if List.mem x (free_variables e2) then unu... |
let rec subst ((e', x) as s) exp = match exp with | Var y -> if x = y then e' else Var y | I n -> I n | B b -> B b | Primop (po, args) -> Primop (po, List.map (subst s) args) | If (e, e1, e2) -> If (subst s e, subst s e1, subst s e2) | Let (y, e1, e2) -> let e1' = subst s e1 in if y = x then Let (y, e1', e2) else let (... |
let rec eval exp = match exp with | I _ -> exp | B _ -> exp | Fn _ -> exp | Var x -> raise (Stuck (Free_variable x)) | Primop (po, args) -> let args = List.map eval args in begin match eval_op po args with | None -> raise (Stuck Bad_primop_args) | Some v -> v end | If (e, e1, e2) -> begin match eval e with | B true -> ... |
let rec infer ctx e = match e with | Var x -> begin try lookup x ctx with Not_found -> raise (TypeError (Free_variable x)) end | I _ -> Int | B _ -> Bool | Primop (po, exps) -> let (domain, range) = primopType po in check ctx exps domain range | If (e, e1, e2) -> begin match infer ctx e with | Bool -> let t1 = infer ct... |
let unify : utp -> utp -> utp UTVarMap.t = let rec unify (substitution : utp UTVarMap.t) (t1 : utp) (t2 : utp) : utp UTVarMap.t = match t1, t2 with | UInt, UInt -> substitution | UBool, UBool -> substitution | UTVar a, UTVar a' when a = a' -> substitution | UArrow (t1, t1'), UArrow (t2, t2') -> unify (unify substitutio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.