Skip to content

Conversation

@akollegger
Copy link
Contributor

This pull request introduces a new CLI feature to the Pattern Lisp tool: conversion between .plisp and .gram file formats using --to-gram and --to-plisp flags. 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:

  • Adds --to-gram and --to-plisp CLI flags to convert .plisp files to .gram format 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]
  • Updates the CLI usage/help output and the README.md installation and usage instructions to document the new conversion functionality and its options. [1] [2]

File Handling and Evaluation Logic:

  • Modifies logic for loading and evaluating files so that, when only .gram files are provided (and no .plisp files), the tool will output the result of the last pattern-lisp gram file if it was successfully evaluated. [1] [2]

Project Planning and Documentation:

  • Updates .cursor/rules/specify-rules.mdc and TODO.md to 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]
  • Enhances examples/README.md to provide direct execution instructions and a status list of working and non-working example programs. [1] [2]

Copy link
Contributor

Copilot AI left a 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 exprToPlisp and valueToPlispSource functions 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)
Copy link

Copilot AI Jan 22, 2026

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.

Copilot uses AI. Check for mistakes.
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)
Copy link

Copilot AI Jan 22, 2026

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.

Copilot uses AI. Check for mistakes.
Right _ -> return ()
else do
-- Value patterns: use gramToProgram + valueToPlispSource
-- Value patterns: use gramToProgram + valueToPlispSource
Copy link

Copilot AI Jan 22, 2026

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).

Suggested change
-- Value patterns: use gramToProgram + valueToPlispSource

Copilot uses AI. Check for mistakes.

## Technical Context

**Language/Version**: Haskell (GHC 4.18+), Cabal 3.x
Copy link

Copilot AI Jan 22, 2026

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.

Suggested change
**Language/Version**: Haskell (GHC 4.18+), Cabal 3.x
**Language/Version**: Haskell (GHC 9.x with base >= 4.18), Cabal 3.x

Copilot uses AI. Check for mistakes.
@akollegger akollegger merged commit a875a32 into main Jan 22, 2026
1 check passed
@akollegger akollegger deleted the 008-plisp-gram-convert branch January 22, 2026 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants