Repl commands

25 views
Skip to first unread message

Ajit Singh

unread,
Aug 6, 2017, 5:06:10 AM8/6/17
to yeti-lang

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`.

Thanks for the help. This language looks really interesting.

Madis Janson

unread,
Aug 6, 2017, 5:25:53 AM8/6/17
to yeti-lang
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
}

Ajit Singh

unread,
Aug 6, 2017, 9:15:41 AM8/6/17
to yeti-lang
Heh, wow that is pleasantly unexpected :). Only printdef is missing and is somewhat mitigated by the structural type.
I'll see if i cant find some useful functions from the yeti.jar source to use with vscode.
Reply all
Reply to author
Forward
0 new messages