zydeco-lang / zydeco

a proof-of-concept programming language based on Call-by-push-value
Other
49 stars 3 forks source link

Enhance the REPL Interface #23

Open maxsnew opened 1 year ago

maxsnew commented 1 year ago

It would be nice to support some additional features in the repl. Let's use this issue as a tracker for what we should support and discuss relevant design/impl issues.

  1. [x] Support running computations of both types Ret(A) and OS
  2. [ ] A way to query the type of a value/expression without running it
  3. [ ] A way to list all names currently in scope

Other suggestions welcome.

LighghtEeloo commented 1 year ago

As for syntax, should we adopt Haskell's approach of :i and :t? Maybe we can have :vtype 1, :ctype ret 1 and :env. It would also be nice if we can have ways to

  1. clear env
  2. (after we have modules) import / open a module
maxsnew commented 1 year ago

WIP on the repl branch

maxsnew commented 1 year ago

I merged in the current version. I think I'll leave it there for now. Now it supports writing values and computations of any type which will be parsed and type-checked, and if the computation is a returner or an OS it will run it.

It doesn't directly support a type-checking interface, but if you have a computation m you can just write { m } and it will display the type it infers. So that's a pretty simple workaround for now. Other features will wait until we add support for libraries etc.

LighghtEeloo commented 1 year ago

Now with #env command shipped in and 7e560e3138df72b1be08c6955f46d239699c4109 introducing #type <term> command to print the type, I'd consider the basic interface done. Further efforts can be made after the basic module system checks in (soon) and with pretty printing implemented for the surface syntax (low-priority).