the error message could be better, but the problem is that a reguarly created proc (with name) is not a value.
There are two solutions:
proc calc(a: int, b: int): (int) -> int =
let diff = a - b
result = proc(c: int): int =
result = c - diff
Run
or
proc calc(a: int, b: int): (int) -> int =
let diff = a - b
proc differentiate(c: int): int =
result = c - diff
differentiate
Run
