TypeCheck is a thing, not sure if it works in IEx. That’s an interesting thought for the library I’m working on, which is compile-time type inference, so I think I’ll toss it on the issues/features list.
Typespec is just annotation and not used at runtime (like @doc).
To raise an error at runtime - you may add guard to functions so that you get no match found error. There are a few libraries to add abstraction for generating typespec and guard…
iex(2)> Sandbox.foo("bing", "bang", "bow")
** (TypeCheck.TypeError) The call `foo("bing", "bang", "bow")` does not adhere to spec `foo(binary(), binary(), float()) :: float()`. Reason:
parameter no. 3:
`"bow"` is not a float.
(arbit 0.1.0) lib/Sandbox.ex:1: Sandbox.foo/3