Skip to content

feat(repl): evaluate Scala worksheets with the REPL - #27007

Open
warcholjakub wants to merge 35 commits into
scala:mainfrom
warcholjakub:feat/repl/worksheet
Open

warcholjakub wants to merge 35 commits into
scala:mainfrom
warcholjakub:feat/repl/worksheet

Conversation

@warcholjakub

@warcholjakub warcholjakub commented Sep 8, 2026

Copy link
Copy Markdown
Member

Adds a worksheet evaluator that's built on the REPL.

Have you relied on LLM-based tools in this contribution?

Yes, and I checked the output by reading and understanding the code.

How was the solution tested?

New automated tests (including the issue's reproducer, if applicable)

@warcholjakub
warcholjakub marked this pull request as draft September 8, 2026 13:39
@warcholjakub warcholjakub changed the title feat(repl): evaluate Scala worksheets with the REPL [WIP] feat(repl): evaluate Scala worksheets with the REPL Sep 8, 2026
@warcholjakub
warcholjakub force-pushed the feat/repl/worksheet branch 3 times, most recently from 36d6906 to 4925315 Compare September 10, 2026 18:06
@warcholjakub warcholjakub changed the title [WIP] feat(repl): evaluate Scala worksheets with the REPL feat(repl): evaluate Scala worksheets with the REPL Sep 11, 2026
@warcholjakub
warcholjakub marked this pull request as ready for review September 11, 2026 09:26
Comment thread project/Build.scala
settings(commonJavaSettings).
settings(
versionScheme := Some("semver-spec"),
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure whether to add MiMa here.

@warcholjakub
warcholjakub force-pushed the feat/repl/worksheet branch 2 times, most recently from 0ecbad3 to c225648 Compare September 11, 2026 10:04
@SolalPirelli

Copy link
Copy Markdown
Contributor

Do we have a spec or documentation somewhere of what worksheets are and how they should behave?

@warcholjakub

Copy link
Copy Markdown
Member Author

Do we have a spec or documentation somewhere of what worksheets are and how they should behave?

Not sure. The main goal of this was to replace mdoc in Metals, so I designed it as closely to mdoc as I could. With a few exceptions ofc. Yeah, but besides that I don't think there's any spec.

@tgodzik

tgodzik commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Do we have a spec or documentation somewhere of what worksheets are and how they should behave?

I would say the spec will be the interfaces that we brought over from mdoc. We can iterate on them for sure, but the main goal is to have an easy way of evaluating whole code snippets. Would also reduce the reliance on compiler internals we have in mdoc.

@SolalPirelli

Copy link
Copy Markdown
Contributor

In that case I'll let someone familiar with mdoc review this... the concept looks OK to me, the idea of doing it on top of the REPL is fine, but I've never used worksheets (my bad!) so I don't know what the code should or shouldn't do in the first place.

@SolalPirelli
SolalPirelli removed their request for review September 11, 2026 11:11
@tgodzik

tgodzik commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

In that case I'll let someone familiar with mdoc review this... the concept looks OK to me, the idea of doing it on top of the REPL is fine, but I've never used worksheets (my bad!) so I don't know what the code should or shouldn't do in the first place.

I will review it next week (I am a bit sick this week, so trying to avoid anything that requires too much thinking.).

Overall, we also wanted to have it on top of REPL to allow for incremental reevaluation, so we would also only evaluate statements starting from the one that changes. With mdoc it would be quite hard and repl is perfect for that.

@bishabosha

Copy link
Copy Markdown
Member

this seems to hand a lot of the responsibilities to the scala 3 repo. Is it better to provide a minimal interface that stays binary compatible (or even a java interface) and the rest is kept in metals?

having said that, it would be interesting to see if there is a common core that works for both worksheet and something like a notebook (preferrably reactive like https://github.com/bishabosha/notebook.sc)

@tgodzik

tgodzik commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

this seems to hand a lot of the responsibilities to the scala 3 repo. Is it better to provide a minimal interface that stays binary compatible (or even a java interface) and the rest is kept in metals?

That would defeat the purpose of the PR. Currently maintaining worksheet is problematic because it heavily interacts with compiler internals. Any larger changes cause problems. Releasing for each version of the compiler separately is also causing a large maintenance burden.

having said that, it would be interesting to see if there is a common core that works for both worksheet and something like a notebook (preferrably reactive like https://github.com/bishabosha/notebook.sc)

That was also an idea we had to make it easier to implement notebook functionality.

@tgodzik

tgodzik commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Also it's not new to have worksheets in the compiler, that was already done in the previous language server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants