-
Notifications
You must be signed in to change notification settings - Fork 6
✨ Haskell #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Haskell #50
Conversation
WalkthroughThis pull request introduces a new Haskell language support package into the system. A changeset entry records the inclusion of Changes
Sequence Diagram(s)sequenceDiagram
participant Tester
participant Nursery
participant Parser
Tester->>Nursery: Initiate Haskell test setup
Nursery->>Parser: Parse sample "let x = 3 in x + x"
Parser-->>Nursery: Return syntax tree
Nursery->>Tester: Validate node type "let_in"
sequenceDiagram
participant App
participant HaskellModule
App->>HaskellModule: Import language registration details
HaskellModule-->>App: Provide libraryPath, extensions, languageSymbol, expandoChar
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
a2407ec
to
cc33798
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (5)
packages/haskell/README.md (1)
1-25
: Enhance README with more comprehensive documentation.While the README provides basic installation and usage instructions, consider enhancing it with:
- A more descriptive introduction about what ast-grep does and why Haskell support is valuable
- Information about prerequisites/requirements
- More detailed examples showing pattern matching or other key features
- Links to related documentation or the main ast-grep project
# ast-grep napi language for haskell + +This package provides Haskell language support for [ast-grep](https://github.com/ast-grep/ast-grep), enabling structural search and pattern matching on Haskell code. ## Installation In a pnpm project, run: ```bash pnpm install @ast-grep/lang-haskell pnpm install @ast-grep/napi # install the tree-sitter-cli if no prebuild is available pnpm install @tree-sitter/cli --save-dev
+### Prerequisites
+
+- Node.js 14 or later
+- pnpm package managerUsage
import haskell from '@ast-grep/lang-haskell' import { registerDynamicLanguage, parse } from '@ast-grep/napi' registerDynamicLanguage({ haskell }) const sg = parse('haskell', `your code`) sg.root().kind()
+### Pattern Matching Example
+
+js +import haskell from '@ast-grep/lang-haskell' +import { registerDynamicLanguage, parse, match } from '@ast-grep/napi' + +registerDynamicLanguage({ haskell }) + +// Parse Haskell code +const code = ` +factorial :: Integer -> Integer +factorial 0 = 1 +factorial n = n * factorial (n - 1) +` + +const sg = parse('haskell', code) + +// Match function definitions +const matches = match(sg, `factorial $_`) +console.log(matches.length) // 2 - matches both factorial patterns +
+
+## Related Links
+
+- ast-grep Documentation
+- Tree-sitter Haskell Grammar</blockquote></details> <details> <summary>packages/haskell/nursery.js (1)</summary><blockquote> `10-15`: **Consider adding error handling to the test runner.** While the current test is straightforward, it would be more robust to include error handling for the case where the pattern might not be found. ```diff testRunner: parse => { const sg = parse('let x = 3 in x + x') const root = sg.root() const node = root.find('let $A = $B in $A + $A') + if (!node) { + throw new Error('Expected pattern was not found in the parsed tree') + } assert.equal(node.kind(), 'let_in') },
packages/haskell/index.js (1)
6-6
: Consider adding support for literate Haskell files.Haskell code can also be written in literate style with the
.lhs
extension. Adding this extension would provide more complete language support.- extensions: ['hs'], + extensions: ['hs', 'lhs'],packages/haskell/package.json (2)
4-4
: Add a meaningful description to the package.The description field is currently empty. Adding a concise description would make the package's purpose clearer to users.
- "description": "", + "description": "Haskell language support for ast-grep",
22-22
: Add author information to the package.The author field is currently empty. Consider adding appropriate author information.
- "author": "", + "author": "ast-grep contributors",
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yaml
is excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (7)
.changeset/slow-rocks-ask.md
(1 hunks)packages/haskell/README.md
(1 hunks)packages/haskell/index.d.ts
(1 hunks)packages/haskell/index.js
(1 hunks)packages/haskell/nursery.js
(1 hunks)packages/haskell/package.json
(1 hunks)packages/haskell/postinstall.js
(1 hunks)
🔇 Additional comments (6)
.changeset/slow-rocks-ask.md (1)
1-6
: Changeset looks good.The changeset correctly identifies the new package and uses the appropriate format with package name, version bump type (patch), and a concise description.
packages/haskell/postinstall.js (1)
1-4
: Implementation looks clean and follows best practices.The post-installation script is concise and follows the correct pattern for language setup. It properly imports the necessary function and passes the current directory.
packages/haskell/index.d.ts (1)
1-10
: Type definitions are clear and well-structured.The
LanguageRegistration
type correctly defines the required and optional properties needed for language registration. The export pattern follows TypeScript conventions.packages/haskell/nursery.js (1)
1-16
: LGTM. Basic test setup for Haskell language support.The nursery setup looks good with a appropriate test case that verifies the Haskell parser correctly identifies the structure of a simple let-in expression.
packages/haskell/index.js (1)
4-9
: LGTM. Proper language registration configuration.The language registration exports all the necessary properties for integrating Haskell with ast-grep.
packages/haskell/package.json (1)
1-47
: LGTM. Package configuration looks correct.The package.json contains all the necessary configurations for building, testing, and publishing the Haskell language support package.
Summary by CodeRabbit
New Features
Documentation
Tests