For some reason, I get that raise
and =
(for the id comparison) are unbound.
type id = stringlet rec lookup (id: id) (storage: (id * 'a) list): 'a = match storage with | [] -> raise Not_found | (id', element)::storage' -> if id = id' then element else lookup id storage'
Also, in this case where value1
and value2
have the type int
, I get that +
is unbound.
let rec interpretExpression (expression: expression) (valueStorage: value_storage) (functionStorage: function_storage): int = match expression with | Id id -> lookup id valueStorage | Int value -> value | Add (expression1, expression2) -> let value1 = interpretExpression expression1 valueStorage functionStorage and value2 = interpretExpression expression2 valueStorage functionStorage in value1 + value2 | FuncApp id -> let expression' = lookup id functionStorage in interpretExpression expression' valueStorage functionStorage
I found many other posts about unbound values for OCaml, but they were about
- Not having evaluated bindings
- Forgetting to use
rec
for recursive functions - Scoping
but raise
, =
, and +
are all part of the core language.
Why I get unbound value for these operations?
Edit: