Skip to main content

dk_engine/parser/langs/
haskell.rs

1//! Haskell language configuration for the query-driven parser.
2
3use crate::parser::lang_config::{CommentStyle, LanguageConfig};
4use dk_core::Visibility;
5use tree_sitter::Language;
6
7/// Haskell language configuration for [`QueryDrivenParser`](crate::parser::engine::QueryDrivenParser).
8pub struct HaskellConfig;
9
10impl LanguageConfig for HaskellConfig {
11    fn language(&self) -> Language {
12        tree_sitter_haskell::LANGUAGE.into()
13    }
14
15    fn extensions(&self) -> &'static [&'static str] {
16        &["hs"]
17    }
18
19    fn symbols_query(&self) -> &'static str {
20        include_str!("../queries/haskell_symbols.scm")
21    }
22
23    fn calls_query(&self) -> &'static str {
24        // Haskell uses whitespace-based function application (not parenthesized
25        // call expressions), making call extraction impractical via queries.
26        include_str!("../queries/haskell_calls.scm")
27    }
28
29    fn imports_query(&self) -> &'static str {
30        include_str!("../queries/haskell_imports.scm")
31    }
32
33    fn comment_style(&self) -> CommentStyle {
34        // Haskell uses `--` for line comments and `-- |` for Haddock doc
35        // comments. The `DashDash` variant correctly strips the `--` prefix.
36        CommentStyle::DashDash
37    }
38
39    fn resolve_visibility(&self, _modifiers: Option<&str>, _name: &str) -> Visibility {
40        // Haskell visibility is controlled by module export lists, not
41        // per-definition modifiers. Default everything to Public.
42        Visibility::Public
43    }
44
45    fn is_external_import(&self, _module_path: &str) -> bool {
46        // Without Cabal/Stack context, we can't distinguish internal
47        // vs external modules. Treat all as external.
48        true
49    }
50}