Skip to content

[ide-mode] Make (:interpret ":version" and ":ops") return output as string instead of S-expression.#3769

Draft
keram wants to merge 3 commits into
idris-lang:mainfrom
keram:ide-mode-interpret-ops
Draft

[ide-mode] Make (:interpret ":version" and ":ops") return output as string instead of S-expression.#3769
keram wants to merge 3 commits into
idris-lang:mainfrom
keram:ide-mode-interpret-ops

Conversation

@keram
Copy link
Copy Markdown
Contributor

@keram keram commented May 1, 2026

Description

Previously, the IDE commands returned a structured S-expression
which wasn't handled well by idris-mode as it expects for interpret always return a string.

See: idris-hackers/idris-mode#661
Although we have "hotfix" in ide-mode idris-hackers/idris-mode#662
I think better to make the change in Idris itself.

This PR supersede #3768
Relates also to https://idris-lang.zulipchat.com/#narrow/channel/556701-general/topic/LLMs.20and.20Idris.202.20programming/near/590513106

Before:

idris2 --ide-mode
((:interpret ":opts") 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)

In Emacs

before-fix-version-opts

After:

$ idris2 --ide-mode
((:interpret ":opts") 3)
00008d(:return (:ok "showimplicits = False
showmachinenames = False
shownamespace = False
showtypes = False
eval = normalise
editor = \"vim\"") 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)

Emacs:

opts-idris-repl-emacs-after

Self-check

  • I've carefully read CONTRIBUTING.md.
  • [] I confirm that this contribution did not involve GenerativeAI nor Large Language Models.

keram added 3 commits April 17, 2026 13:35
… command

Previously, the IDE command `:version` (via `interpret`) reused
`ShowVersion` and returned a structured S-expression containing
semantic version components and commit hash.

As `idris-mode` expects for output of `:interpret` command to be always a string.
This leads to bad user experience on commands that return S-expression.
See: idris-hackers/idris-mode#661
and idris-hackers/idris-mode#662

This introduces a dedicated `VersionSExp` constructor in
`IDEResult` and updates `process Version` to return the raw `version`
value directly.
The IDE mode now distinguishes between:

 - `REPL (VersionIs x)` -> structured `AVersion` (unchanged)
 - `VersionSExp x`      -> formatted string via `showVersion`

As a result, `:version` in IDE interpret mode now produces
a human-readable string (e.g. "0.8.0-<hash>") instead of a structured tuple.

 Before:

```
idris2 --ide-mode
000018(:protocol-version 2 1)
(:version 1)
00002a(:return (:ok ((0 8 0) ("19a3f4ec0"))) 1)
((:interpret ":version") 2)
00002a(:return (:ok ((0 8 0) ("19a3f4ec0"))) 2)
```

 After:

```
$ idris2 --ide-mode
000018(:protocol-version 2 1)
(:version 1)
00002a(:return (:ok ((0 8 0) ("ed55358b6"))) 1)
((:interpret ":version") 2)
000024(:return (:ok "0.8.0-ed55358b6") 2)
```

 Next steps:

Update `:opts` command in similar way.
```
((:interpret ":opts") 3)
00009b(:return (:ok ((:show-implicits :False) ...)) 3) ;; should be string
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) .. (:editor "vim"))) 3) ;; stay same
```
… IDE command

Previously, the `:interpret ":opts"` returned a list of S-expression same as
`((:get-options) n)`

This leads to bad user experience at least in Emacs
See: idris-hackers/idris-mode#661
and idris-hackers/idris-mode#662

This change distinguish between `:get-options` to return original S-expression
and `:interpret ":opts" to return formatted options as a string.

 Before:

```
idris2 --ide-mode
((:interpret ":opts") 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
```

 After:

```
$ idris2 --ide-mode
((:interpret ":opts") 3)
00008d(:return (:ok "showimplicits = False
showmachinenames = False
shownamespace = False
showtypes = False
eval = normalise
editor = \"vim\"") 3)
((:get-options) 3)
00009b(:return (:ok ((:show-implicits :False) (:show-machinenames :False) (:show-namespace :False) (:show-types :False) (:eval "normalise") (:editor "vim"))) 3)
```

Relates to:
idris-lang#3768
| VersionSExp Version
| OptionsSExp (List REPLOpt)

getOptions : {auto c : Ref Ctxt Defs} ->
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is copy-paste from Idris/REPL.idr https://github.com/idris-lang/Idris2/blob/main/src/Idris/REPL.idr#L191 as when trying reusing it here got an error.

Error: While processing right hand side of process. 
Name Idris.REPL.getOptions is private.
...
Suggestion: add an explicit export or public export modifier. 

I don't know which is the right suggested solution or some other better way to get the opts.

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.

1 participant