Skip to content

Add support for haskell-debugger#33

Open
rajcspsg wants to merge 8 commits into
zed-extensions:mainfrom
rajcspsg:haskell-debugger-support
Open

Add support for haskell-debugger#33
rajcspsg wants to merge 8 commits into
zed-extensions:mainfrom
rajcspsg:haskell-debugger-support

Conversation

@rajcspsg

@rajcspsg rajcspsg commented May 11, 2026

Copy link
Copy Markdown

closes #12

screen recording for debugger support

@cla-bot

cla-bot Bot commented May 11, 2026

Copy link
Copy Markdown

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Rajkumar Natarajan.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@rajcspsg rajcspsg force-pushed the haskell-debugger-support branch from c4bf776 to a7133e9 Compare May 11, 2026 02:26
@cla-bot

cla-bot Bot commented May 11, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @rajcspsg on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@rajcspsg

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label May 11, 2026
@cla-bot

cla-bot Bot commented May 11, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

@MrSubidubi MrSubidubi changed the title issue-12: added support for haskell-debugger Add support for haskell-debugger May 11, 2026
MrSubidubi
MrSubidubi previously approved these changes May 11, 2026

@MrSubidubi MrSubidubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for this!

Preliminary review, will do my best to get back to this in a timely manner again

Comment thread src/language_server.rs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's call this language_server.rs instead

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just wondering why this change: haskell.rs -> language_server.rs is needed.

It might be fine from Rust perspective, but by following folder structures of other Zed extension, especially with debuggers included), most extensions name its main entry file as same as the language.

Just to mention few (randomly - all with debugger support):

Comment thread extension.toml Outdated
name = "Haskell"
description = "Haskell support."
version = "0.2.1"
version = "0.2.2"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ci will lint this, but that will be done after automatically (and will be minor at least)

Comment thread src/debugger.rs Outdated
Comment thread src/debugger.rs Outdated
Co-authored-by: Finn Evers <finn.evers@outlook.de>
Comment thread Cargo.lock Outdated
@rajcspsg

Copy link
Copy Markdown
Author

@MrSubidubi incorporated your review comments

@MrSubidubi

Copy link
Copy Markdown
Contributor

Will try to get back to you with a final review this week, apologies for the delay!

@sectore sectore left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great addition. Just tested it on my local machine and it works great.

Tested manually with:

ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.14.1

hdb --version
Haskell Debugger, version 0.13.1.0

zeditor --version
Zed 1.6.3

Just few nits have been added from my side.

Comment thread src/debugger.rs
format!("Invalid Haskell debug configuration (expected JSON object): {err}")
})?;
map.entry("type".to_string())
.or_insert_with(|| json!(HASKELL_DEBUG_ADAPTER));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(nit) or_insert_with -> or_insert

.or_insert(json!(HASKELL_DEBUG_ADAPTER));

Comment thread src/debugger.rs
map.entry("type".to_string())
.or_insert_with(|| json!(HASKELL_DEBUG_ADAPTER));
map.entry("request".to_string())
.or_insert_with(|| json!("launch"));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(nit) or_insert_with -> or_insert

.or_insert(json!("launch"));

Comment thread src/debugger.rs
map.entry("request".to_string())
.or_insert_with(|| json!("launch"));
map.entry("name".to_string())
.or_insert_with(|| json!(task.label.clone()));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(nit) or_insert_with -> or_insert

.or_insert(json!(task.label.clone()));

Comment thread src/debugger.rs
Comment on lines +71 to +95
fn path_components_to_string(path: &Path) -> Result<String, String> {
let mut out = String::new();
for (i, component) in path.components().enumerate() {
match component {
Component::Normal(part) => {
if i > 0 {
out.push(std::path::MAIN_SEPARATOR);
}
out.push_str(&part.to_string_lossy());
}
Component::CurDir => {}
Component::ParentDir => {
return Err("Program path must not contain `..`.".into());
}
Component::RootDir | Component::Prefix(_) => {
return Err("Invalid program path.".into());
}
}
}
if out.is_empty() {
Err("Resolved entry file path is empty.".into())
} else {
Ok(out)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(nit) path_components_to_string function can be more compact. No mutation of out: String, no loop, no if i > 0 check needed anymore.

fn path_components_to_string(path: &Path) -> Result<String, String> {
    path.components()
        .filter_map(|c| match c {
            Component::Normal(part) => Some(Ok(part.to_string_lossy().into_owned())),
            Component::CurDir => None,
            Component::ParentDir => Some(Err("Program path must not contain `..`.".into())),
            _ => Some(Err("Invalid program path.".into())),
        })
        .collect::<Result<Vec<_>, _>>()
        .and_then(|parts| {
            if parts.is_empty() {
                Err("Resolved entry file path is empty.".into())
            } else {
                Ok(parts.join(std::path::MAIN_SEPARATOR_STR))
            }
        })
}

Comment thread src/language_server.rs
adapter_name: String,
config: zed::serde_json::Value,
) -> Result<StartDebuggingRequestArgumentsRequest, String> {
crate::debugger::dap_request_kind(adapter_name.as_str(), &config)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

(nit-nit) &adapter_name if you want save as_str(). Just in case :)

Comment thread src/language_server.rs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Just wondering why this change: haskell.rs -> language_server.rs is needed.

It might be fine from Rust perspective, but by following folder structures of other Zed extension, especially with debuggers included), most extensions name its main entry file as same as the language.

Just to mention few (randomly - all with debugger support):

Comment thread Cargo.toml

[lib]
path = "src/haskell.rs"
path = "src/lib.rs"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread src/debugger.rs
}
out.push_str(&part.to_string_lossy());
}
Component::CurDir => {}

@sectore sectore Jun 21, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

By enumerating and counting i, CurDir of ./src/Main.hs will become /src/Main.hs. Even by skipping CurDir by {}, next count of i runs Component::Normal again and adds the leading /.

That's a bug and can be fixed with a suggested change in this comment

@sectore

sectore commented Jun 22, 2026

Copy link
Copy Markdown

Will try to get back to you with a final review this week, apologies for the delay!

@MrSubidubi Any chance for another review? Pls consider latest review comments.

cc/ @rajcspsg

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add debug adapter for haskell-debugger

3 participants