Style more consistent, replace capitalization with camel case
This commit is contained in:
@ -6,7 +6,7 @@ Random.self_init ()
|
||||
let (let*) = Result.bind
|
||||
|
||||
let rec evaluate (mem: memory) (command: t_exp) :
|
||||
(permittedValues, [> error]) result =
|
||||
(permitted_values, [> error]) result =
|
||||
match command with
|
||||
Integer n -> Ok (IntegerPermitted n)
|
||||
| Boolean b -> Ok (BooleanPermitted b)
|
||||
@ -31,7 +31,7 @@ let rec evaluate (mem: memory) (command: t_exp) :
|
||||
)
|
||||
| Application (f, x) -> (
|
||||
let* evalf = evaluate mem f in
|
||||
let* funcClosure = (
|
||||
let* func_closure = (
|
||||
match evalf with
|
||||
FunctionPermitted ff -> Ok ff
|
||||
| IntegerPermitted _ -> Error (`WrongType ("Function is not a function,"
|
||||
@ -43,15 +43,15 @@ let rec evaluate (mem: memory) (command: t_exp) :
|
||||
) in
|
||||
let* param = evaluate mem x in
|
||||
let mem2 =
|
||||
match funcClosure.recursiveness with
|
||||
match func_closure.recursiveness with
|
||||
None -> {assignments = (
|
||||
VariableMap.add funcClosure.input param funcClosure.assignments)}
|
||||
VariableMap.add func_closure.input param func_closure.assignments)}
|
||||
| Some nameF -> {assignments = (
|
||||
VariableMap.add funcClosure.input param funcClosure.assignments |>
|
||||
VariableMap.add nameF (FunctionPermitted funcClosure)
|
||||
VariableMap.add func_closure.input param func_closure.assignments |>
|
||||
VariableMap.add nameF (FunctionPermitted func_closure)
|
||||
)}
|
||||
in
|
||||
evaluate mem2 funcClosure.body
|
||||
evaluate mem2 func_closure.body
|
||||
)
|
||||
| Plus (a, b) ->
|
||||
let* aval = (
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
val evaluate : Types.memory -> Types.t_exp -> (Types.permittedValues, [> Types.error]) result
|
||||
val evaluate : Types.memory -> Types.t_exp -> (Types.permitted_values, [> Types.error]) result
|
||||
|
||||
val reduce : Types.t_exp -> int -> (int, [> Types.error]) result
|
||||
|
||||
@ -38,20 +38,20 @@ type t_exp =
|
||||
| LetFun of variable * variable * ftype * t_exp * t_exp
|
||||
(* let rec x. y: t. x in x*)
|
||||
|
||||
type permittedValues =
|
||||
type permitted_values =
|
||||
IntegerPermitted of int
|
||||
| BooleanPermitted of bool
|
||||
| TuplePermitted of permittedValues * permittedValues
|
||||
| TuplePermitted of permitted_values * permitted_values
|
||||
| FunctionPermitted of closure
|
||||
and closure = {
|
||||
input: variable;
|
||||
body: t_exp;
|
||||
assignments: permittedValues VariableMap.t;
|
||||
assignments: permitted_values VariableMap.t;
|
||||
recursiveness: variable option
|
||||
}
|
||||
|
||||
type memory = {
|
||||
assignments: permittedValues VariableMap.t
|
||||
assignments: permitted_values VariableMap.t
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -37,20 +37,20 @@ type t_exp =
|
||||
| LetIn of variable * t_exp * t_exp (* let x = x in x *)
|
||||
| LetFun of variable * variable * ftype * t_exp * t_exp (* let rec x. y: t. x in x*)
|
||||
|
||||
type permittedValues =
|
||||
type permitted_values =
|
||||
IntegerPermitted of int
|
||||
| BooleanPermitted of bool
|
||||
| TuplePermitted of permittedValues * permittedValues
|
||||
| TuplePermitted of permitted_values * permitted_values
|
||||
| FunctionPermitted of closure
|
||||
and closure = {
|
||||
input: variable;
|
||||
body: t_exp;
|
||||
assignments: permittedValues VariableMap.t;
|
||||
assignments: permitted_values VariableMap.t;
|
||||
recursiveness: variable option
|
||||
}
|
||||
|
||||
type memory = {
|
||||
assignments: permittedValues VariableMap.t
|
||||
assignments: permitted_values VariableMap.t
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user