[ide-mode] Make (:interpret ":version" and ":ops") return output as string instead of S-expression.#3769
Draft
keram wants to merge 3 commits into
Draft
[ide-mode] Make (:interpret ":version" and ":ops") return output as string instead of S-expression.#3769keram wants to merge 3 commits into
(:interpret ":version" and ":ops") return output as string instead of S-expression.#3769keram wants to merge 3 commits into
Conversation
… 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
keram
commented
May 1, 2026
| | VersionSExp Version | ||
| | OptionsSExp (List REPLOpt) | ||
|
|
||
| getOptions : {auto c : Ref Ctxt Defs} -> |
Contributor
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Previously, the IDE commands returned a structured S-expression
which wasn't handled well by
idris-modeas it expects forinterpretalways return a string.See: idris-hackers/idris-mode#661
Although we have "hotfix" in
ide-modeidris-hackers/idris-mode#662I 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:
In Emacs
After:
Emacs:
Self-check
CONTRIBUTING.md.