Ariety to arity

This commit is contained in:
elvis
2024-10-24 16:27:21 +02:00
parent 0c9490780a
commit 733834a5a7
2 changed files with 6 additions and 6 deletions

View File

@ -51,7 +51,7 @@ type memory = {
exception AbsentAssignment of string exception AbsentAssignment of string
exception WrongType of string exception WrongType of string
exception DivisionByZero of string exception DivisionByZero of string
exception WrongAriety of string exception WrongArity of string
exception WrongTypeSpecification of string exception WrongTypeSpecification of string
module Utility = Utility;; module Utility = Utility;;
@ -88,7 +88,7 @@ let rec evaluate (mem: memory) (command: t_exp) =
match (params, values) with match (params, values) with
(_, []) -> (m, params) (_, []) -> (m, params)
| ([], _) -> | ([], _) ->
raise (WrongAriety ("Function application has arity " ^ raise (WrongArity ("Function application has arity " ^
(List.length funcClosure.inputList (List.length funcClosure.inputList
|> string_of_int) ^ |> string_of_int) ^
", but was applied to " ^ ", but was applied to " ^
@ -377,7 +377,7 @@ let rec evaluate_type (program: t_exp) context =
match typef with match typef with
FunctionType (tin, tout) -> ( FunctionType (tin, tout) -> (
if List.length xs != List.length tin then if List.length xs != List.length tin then
raise (WrongTypeSpecification "Type specification for function has wrong ariety.") raise (WrongTypeSpecification "Type specification for function has wrong arity.")
else else
let context1 = List.fold_left2 (fun acc x t -> VariableMap.add x t acc) context xs tin in let context1 = List.fold_left2 (fun acc x t -> VariableMap.add x t acc) context xs tin in
match (evaluate_type fbody context1 = tout) with match (evaluate_type fbody context1 = tout) with
@ -392,7 +392,7 @@ let rec evaluate_type (program: t_exp) context =
let rec helper params typeparams = let rec helper params typeparams =
match (params, typeparams) with match (params, typeparams) with
([], _) -> typeparams ([], _) -> typeparams
| (_, []) -> raise (WrongAriety ("Function application has arity " ^ | (_, []) -> raise (WrongArity ("Function application has arity " ^
(List.length tin |> string_of_int) ^ (List.length tin |> string_of_int) ^
", but was applied to " ^ ", but was applied to " ^
(List.length xs |> string_of_int) ^ (List.length xs |> string_of_int) ^
@ -471,7 +471,7 @@ let rec evaluate_type (program: t_exp) context =
match typef with match typef with
FunctionType (tin, tout) -> ( FunctionType (tin, tout) -> (
if List.length xs != List.length tin then if List.length xs != List.length tin then
raise (WrongAriety "Type specification for function has wrong ariety.") raise (WrongArity "Type specification for function has wrong arity.")
else else
let context1 = VariableMap.add f typef context in let context1 = VariableMap.add f typef context in
let context2 = List.fold_left2 (fun acc x t -> VariableMap.add x t acc) context1 xs tin in let context2 = List.fold_left2 (fun acc x t -> VariableMap.add x t acc) context1 xs tin in

View File

@ -50,7 +50,7 @@ type memory = {
exception AbsentAssignment of string exception AbsentAssignment of string
exception WrongType of string exception WrongType of string
exception DivisionByZero of string exception DivisionByZero of string
exception WrongAriety of string exception WrongArity of string
exception WrongTypeSpecification of string exception WrongTypeSpecification of string
val reduce : t_exp -> int -> int val reduce : t_exp -> int -> int