modular / modular/modular

[Mojo]: Verbose REPL due to double Enter

Open
#1,350 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug Initiative: REPL/Jupyter mojo mojo-repo
Dominant language
Mojo
Stars
29.8k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Issue description

Currently, evaluating code on the Mojo REPL requires pressing Enter twice:

Welcome to Mojo! 🔥

Expressions are delimited by a blank line.
Type `:quit` to exit the REPL and `:mojo help` for further assistance.

  1> x = 1
  2.
(Int) x = 1
  2> print(x)
  3.
1

This leads to verbose output when copy pasting output from the REPL. Or when talking about code snippets on a forum.

In comparison, Julia has a clean REPL which, I think, is a nice feature of the language. Most Julia packages have REPL examples ready which allow users to quickly try out the package. For example, the following is an example from a repository of mine which shows how to use some algorithm (SIRUS in this case) in combination with the Julia Machine Learning interface. This example can be copy pasted as a whole into a Julia REPL and it will parse the whole block and execute all the steps.

julia> using MLJ, SIRUS

julia> X, y = make_blobs(200, 10; centers=2);

julia> X
Tables.MatrixTable{Matrix{Float64}} with 200 rows, 10 columns, and schema:
 :x1   Float64
 :x2   Float64
 :x3   Float64
 :x4   Float64
 :x5   Float64
 :x6   Float64
 :x7   Float64
 :x8   Float64
 :x9   Float64
 :x10  Float64

julia> y
200-element CategoricalArrays.CategoricalArray{Int64,1,UInt32}:
 2
 1
 1
 ⋮
 2
 1
 2

julia> model = StableRulesClassifier();

julia> mach = machine(model, X, y);

julia> fit!(mach);

julia> mach.fitresult
StableRules model with 7 rules:
 if X[i, :x5] < -1.552594 then 0.129 else 0.0 +
 if X[i, :x8] < 0.72402614 then 0.117 else 0.0 +
 if X[i, :x2] < 7.1123967 then 0.123 else 0.0 +
 if X[i, :x8] < 8.840833 then 0.115 else 0.0 +
 if X[i, :x9] < 7.985747 then 0.0 else 0.001 +
 if X[i, :x7] < 6.4651833 then 0.107 else 0.0 +
 if X[i, :x7] < 2.2220817 then 0.119 else 0.024
and 2 classes: [1, 2].
Note: showing only the probability for class 2 since class 1 has probability 1 - p.
Steps to reproduce

See previous.

Version Info
- Provide Modular CLI version by pasting the output of `modular -v`

modular 0.2.2 (95d42445)

- What OS did you install modular CLI on ?

MacOS aarch64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the double-Enter behavior in the Mojo REPL with the assignment and print examples shown in the issue, then inspect the REPL input handling entry point. Done means complete expressions and pasted multiline snippets execute without requiring a blank line and without the extra verbose prompts.

Written by the indexing model from the issue text.

Assessment

Domain
cli, developer-experience
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.