-
Notifications
You must be signed in to change notification settings - Fork 0
008 plisp gram convert #10
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
Conversation
…p and gram notation. should be 1:1 but some gram is 'just data' rather than code. figure it out
…gram conversion option
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.
Pull request overview
This pull request introduces CLI conversion functionality to Pattern Lisp, enabling bidirectional conversion between .plisp and .gram file formats using --to-gram and --to-plisp flags. The feature includes comprehensive testing, robust error handling, file path management, and extensive documentation updates.
Changes:
- Adds CLI flags (
--to-gram,--to-plisp,-o/--output) for file format conversion with automatic output path derivation - Implements
exprToPlispandvalueToPlispSourcefunctions for serializing Pattern Lisp expressions and values to source code - Enhances gram file handling to detect and evaluate pattern-lisp programs while maintaining backward compatibility for regular gram files
- Updates project documentation including installation instructions, conversion examples, and deferred work tracking
Reviewed changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| app/Main.hs | Adds CLI argument parsing and conversion logic for --to-gram and --to-plisp modes with error handling |
| src/PatternLisp/Codec.hs | Implements exprToPlisp, valueToPlispSource, exprProgramToGram, gramToExprProgram and related helpers |
| src/PatternLisp/Gram.hs | Updates patternToGram and gramToPattern to work with list-based gram serialization |
| src/PatternLisp/FileLoader.hs | Enhances gram file loading to detect and evaluate pattern-lisp programs vs regular pattern subjects |
| test/PatternLisp/ConvertSpec.hs | Comprehensive integration tests for conversion features including round-trips and error cases |
| test/PatternLisp/CodecSpec.hs | Adds unit tests for exprToPlisp and valueToPlispSource serialization functions |
| test/IntegrationSpec.hs | Adds round-trip integration tests for plisp↔gram conversion |
| pattern-lisp.cabal | Adds dependencies: filepath, process, directory, temporary for conversion and testing |
| README.md | Updates installation and usage instructions with conversion examples |
| examples/*.plisp | Corrects syntax issues in example files (define vs def, commas in records) |
| specs/008-plisp-gram-convert/* | Complete feature specification, design documents, and task breakdown |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| - N/A (in-memory pattern structures) (006-gram-hs-migration) | ||
| - Haskell (GHC 9.10.3, base >=4.18 && <5) + gram-hs library (gram, pattern, subject packages), Megaparsec (parsing), Data.Map.Strict (record representation), Cabal build system (007-inline-record-notation) | ||
| - N/A (in-memory record structures) (007-inline-record-notation) | ||
| - Haskell (GHC 4.18+), Cabal 3.x + megaparsec, mtl, gram, pattern, subject, filepath (existing) (008-plisp-gram-convert) |
Copilot
AI
Jan 22, 2026
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.
GHC version appears to be incorrect. The version is listed as "GHC 4.18+" but GHC versions follow a different numbering scheme (e.g., GHC 9.6.3, 9.10.3). This should likely be "GHC 9.x with base >= 4.18" or similar, based on other references in the codebase that mention GHC 9.6.3 and GHC 9.10.3.
| Haskell with GHC 9.6.3 (see research.md for version selection rationale): Follow standard conventions | ||
|
|
||
| ## Recent Changes | ||
| - 008-plisp-gram-convert: Added Haskell (GHC 4.18+), Cabal 3.x + megaparsec, mtl, gram, pattern, subject, filepath (existing) |
Copilot
AI
Jan 22, 2026
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.
GHC version appears to be incorrect. The version is listed as "GHC 4.18+" but GHC versions follow a different numbering scheme (e.g., GHC 9.6.3, 9.10.3). This should likely be "GHC 9.x with base >= 4.18" or similar, based on other references in the codebase that mention GHC 9.6.3 and GHC 9.10.3.
| Right _ -> return () | ||
| else do | ||
| -- Value patterns: use gramToProgram + valueToPlispSource | ||
| -- Value patterns: use gramToProgram + valueToPlispSource |
Copilot
AI
Jan 22, 2026
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.
Duplicate comment "Value patterns: use gramToProgram + valueToPlispSource" should be removed (appears on both lines 256 and 257).
| -- Value patterns: use gramToProgram + valueToPlispSource |
|
|
||
| ## Technical Context | ||
|
|
||
| **Language/Version**: Haskell (GHC 4.18+), Cabal 3.x |
Copilot
AI
Jan 22, 2026
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.
GHC version appears to be incorrect. The version is listed as "GHC 4.18+" but GHC versions follow a different numbering scheme (e.g., GHC 9.6.3, 9.10.3). This should likely be "GHC 9.x with base >= 4.18" or similar, based on other references in the codebase that mention GHC 9.6.3 and GHC 9.10.3.
| **Language/Version**: Haskell (GHC 4.18+), Cabal 3.x | |
| **Language/Version**: Haskell (GHC 9.x with base >= 4.18), Cabal 3.x |
This pull request introduces a new CLI feature to the Pattern Lisp tool: conversion between
.plispand.gramfile formats using--to-gramand--to-plispflags. It also adds robust error handling, output file path management, and updates to documentation to reflect these changes. Additionally, it clarifies the handling of gram files that do not contain pattern-lisp programs and updates project planning documents to reflect the new conversion feature and its dependencies.Major CLI and Conversion Features:
--to-gramand--to-plispCLI flags to convert.plispfiles to.gramformat and vice versa, with automatic or user-specified output paths. Includes robust error handling for file I/O and parsing, and ensures correct conversion for both expression and value patterns. [1] [2]README.mdinstallation and usage instructions to document the new conversion functionality and its options. [1] [2]File Handling and Evaluation Logic:
.gramfiles are provided (and no.plispfiles), the tool will output the result of the last pattern-lisp gram file if it was successfully evaluated. [1] [2]Project Planning and Documentation:
.cursor/rules/specify-rules.mdcandTODO.mdto add and clarify the new "Plisp–Gram Convert CLI" feature, its dependencies, and deferred work for handling non-pattern-lisp gram files. [1] [2] [3] [4]examples/README.mdto provide direct execution instructions and a status list of working and non-working example programs. [1] [2]