Skip to content

Commit 97c558f

Browse files
unhappychoiceclaude
andcommitted
feat: register Haskell language in core system
- Add Haskell variant to Language enum with file extensions - Include Haskell file patterns in default extraction options - Register Haskell parser in parser module registry 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 47d0899 commit 97c558f

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

src/extractor/models/language.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub enum Language {
1313
CSharp,
1414
C,
1515
Cpp,
16+
Haskell,
1617
}
1718

1819
impl std::fmt::Display for Language {
@@ -31,6 +32,7 @@ impl std::fmt::Display for Language {
3132
Language::CSharp => "csharp",
3233
Language::C => "c",
3334
Language::Cpp => "cpp",
35+
Language::Haskell => "haskell",
3436
};
3537
write!(f, "{}", s)
3638
}
@@ -52,6 +54,7 @@ impl Language {
5254
"cs" | "csx" => Some(Language::CSharp),
5355
"c" | "h" => Some(Language::C),
5456
"cpp" | "cc" | "cxx" | "hpp" => Some(Language::Cpp),
57+
"hs" | "lhs" => Some(Language::Haskell),
5558
_ => None,
5659
}
5760
}
@@ -71,6 +74,7 @@ impl Language {
7174
Language::CSharp => "cs",
7275
Language::C => "c",
7376
Language::Cpp => "cpp",
77+
Language::Haskell => "hs",
7478
}
7579
}
7680

@@ -91,6 +95,7 @@ impl Language {
9195
Some("cs") | Some("csx") => "csharp".to_string(),
9296
Some("c") | Some("h") => "c".to_string(),
9397
Some("cpp") | Some("cc") | Some("cxx") | Some("hpp") => "cpp".to_string(),
98+
Some("hs") | Some("lhs") => "haskell".to_string(),
9499
_ => "text".to_string(),
95100
}
96101
}

src/extractor/models/options.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ impl Default for ExtractionOptions {
3535
"**/*.cc".to_string(),
3636
"**/*.cxx".to_string(),
3737
"**/*.hpp".to_string(),
38+
"**/*.hs".to_string(),
39+
"**/*.lhs".to_string(),
3840
],
3941
exclude_patterns: vec![
4042
"**/target/**".to_string(),

src/extractor/parsers/mod.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub mod c;
99
pub mod cpp;
1010
pub mod csharp;
1111
pub mod go;
12+
pub mod haskell;
1213
pub mod java;
1314
pub mod javascript;
1415
pub mod kotlin;
@@ -109,6 +110,12 @@ impl ParserRegistry {
109110
Box::new(cpp::CppExtractor)
110111
});
111112

113+
registry.register(
114+
Language::Haskell,
115+
haskell::HaskellExtractor::create_parser,
116+
|| Box::new(haskell::HaskellExtractor),
117+
);
118+
112119
registry
113120
}
114121

@@ -145,7 +152,7 @@ impl ParserRegistry {
145152
let tree_sitter_lang = extractor.tree_sitter_language();
146153
let query_str = extractor.query_patterns();
147154

148-
Query::new(tree_sitter_lang, query_str).map_err(|e| {
155+
Query::new(&tree_sitter_lang, query_str).map_err(|e| {
149156
GitTypeError::ExtractionFailed(format!(
150157
"Failed to create query for {:?}: {}",
151158
language, e
@@ -158,7 +165,7 @@ impl ParserRegistry {
158165
let tree_sitter_lang = extractor.tree_sitter_language();
159166
let query_str = extractor.comment_query();
160167

161-
Query::new(tree_sitter_lang, query_str).map_err(|e| {
168+
Query::new(&tree_sitter_lang, query_str).map_err(|e| {
162169
GitTypeError::ExtractionFailed(format!(
163170
"Failed to create comment query for {:?}: {}",
164171
language, e

0 commit comments

Comments
 (0)