On Sun, 6 Aug 2017, Ajit Singh wrote:
> Is there a way to get the type of an expression or to print it's definition from within the repl? It would be
> really helpful in development.
> If it's not there, I was wondering how much work would it be to add it to the interpreter. It probably
> already has the type inference and definition functions so probably the only thing that's required is the
> ability to expose it at the repl. Something like `:t expr` and `:printdef name`.
Definitions are not available to the REPL, but type is printed any time
when you evaluate something in the REPL.
> 1 + 2
3 is number
If you want to avoid actually running the code, a lambda can be used:
> \(1 + 2)
<code$> is 'a -> number
It is also possible to get typedef definitions.
> readFile
<
yeti.lang.io$readFile> is string -> string -> (input_handle -> 'a) -> 'a
So what the input_handle type contains?
> input_handle is
{
close is () -> (),
contents is () -> string,
lines is () -> list<string>,
rawClose is () -> (),
read is number -> string,
readln is () -> string
}