In Type-Driven Development with Idris, ch 6, he says
- Type-level functions exist at compile time only ...
- Only functions that are total will be evaluated at the type level. A function that isn't total may not terminate, or may not cover all possible inputs. Therefore, to ensure that type-checking itself terminates, functions that are not total are treated as constants at the type level, and don't evaluate further.
I'm having difficulty understanding what the second bullet point means.
- How could the type checker claim the code type checks if there's a function that isn't total in its signature? Wouldn't there by definition be some inputs for which the type isn't defined?
- When he says constant, does he mean in the same sense as in the docs, like
is a constant? If so, how could that enable the type checker to complete its job?one: Nat one = 1
- If a type-level function exists at compile time only, does it ever get evaluated if it's not total? If not, what purpose does it serve?