I know we've talked before about ways to improve the repl, and I'd love for it to get some more love in the short term. What do folks think of this idea for supporting top-level definitions, so you can play around with things like abilities in the repl too?
> myFunc =
> <keep parsing>
when a definition is parsed as completed, print out the def name and its type
> myFunc =
> \x -> x
myFunc : a -> a
this also supports multi-line aliases and abilities:
> MyAbility has
> <keep parsing>
> MyAbility has
> f : a, a -> a | a has MyAbility
>
>
MyAbility : ability (Making this line up, it could be improved)
> myFunc 1
1 : Num *
If you want to bail out of an expression without it being parsed and evaluated at all, you can do that with <Ctrl-C> (SIGINT) now.
You'll be able to over-write definitions - if you do something like
> y = 1
y : Num *
> y = 2
y : Num *
Subsequent expressions that use y will use the second definition. However, ambiguous definitions, like conflicts during record destructuring, will be errors.
> {a, b} = {a: 1, b: 2}
{a, b} : {a: Num *, b: Num *}
> {a, c} = {a: 1, c: 2}
-- CONFLICTING DEFINITION --
`a` is defined in two separate record destructurings in this repl session, that don't each introduce the same variables.
I could see arguments against this though, for similar anti-shadow reasons as Roc files have. Curious what others think
These are small changes but I think they'll dramatically improve the QoL in the repl. Thoughts?
Tiny proposal - every unassigned expression is assigned to an autogenerated variable name like some web browser dev tools do? Maybe var1, var2, etc.
This saves copy/paste work when exploring expressions and wanting to reuse them
Everything you proposed sounds great
For the online REPL, multi line input works differently. You type multiple lines into a textarea using Shift-Enter for newlines,, and then submit it all at once.
This is because the rustyline library doesn't work on the web so I decided to do something more "web native". There is some JS code to detect hitting the up and down arrows to go back through history.
The point is that the "hit enter 3 times" thing might be different. We might not need it.
Or alternatively we could change the way the online version works to be more like the CLI. That might be a bit more work to replicate anything rustyline does.
Yeah that’s a good point Brian. Personally I think it would be nice if we could avoid shift+enter but I think it’s okay if the web and cli version are a bit different
Last updated: Jun 16 2026 at 16:19 UTC