Skip to content
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

Refactor CLI and docs #153

Merged

Conversation

deemp
Copy link
Member

@deemp deemp commented Feb 26, 2024

CLI

Docs

  • move docs from README to site
  • use mdsh to run commands in .md files

PR-Codex overview

This PR updates the normalizer executable in the Haskell project. It adds new commands, modifies dependencies, and enhances documentation.

Detailed summary

  • Added new commands and updated existing ones for normalizer executable.
  • Modified dependencies including adding optparse-applicative and aeson-pretty.
  • Updated documentation for installation, introduction, and contributing.
  • Introduced CLI commands for metrics and transformation.
  • Improved sample program and provided uninstallation instructions.

The following files were skipped due to too many changes: site/docs/src/contributing.md, eo-phi-normalizer/app/Main.hs, site/docs/src/commands/normalizer-transform.md, README.md

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

@deemp deemp linked an issue Feb 26, 2024 that may be closed by this pull request
@deemp deemp requested a review from fizruk February 26, 2024 13:32
@deemp deemp changed the title 147 add a command to print metrics for a given phi expression refactor CLI Feb 26, 2024
@deemp deemp marked this pull request as draft February 26, 2024 23:37
README.md Outdated Show resolved Hide resolved
@deemp deemp marked this pull request as ready for review February 27, 2024 20:37
@deemp deemp changed the title refactor CLI Refactor CLI and docs Feb 27, 2024
@deemp deemp mentioned this pull request Feb 27, 2024
1 task
@deemp deemp requested a review from aabounegm February 27, 2024 21:31
Copy link
Collaborator

@aabounegm aabounegm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I would prefer if we keep the unpopular extensions or those that just provide (unintuitive) gimmicks to a minimum 🙂

, single :: Bool
, json :: Bool
, inputFile :: Maybe FilePath
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you make it a named parameter instead of positional?

Copy link
Member Author

@deemp deemp Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to support reading a program:

  1. from a file: --input-file program.phi
  2. from an option: --program "{ ⟦ ⟧ }"
  3. from stdin: --input-file -

So, I read from stdin only in the case 3.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with these. I think what we already had is more idiomatic and we already supported all three cases:

  1. normalizer transform program.phi
  2. echo "{ ⟦ ⟧ }" | normalizer transform
  3. normalizer transform

This is what I think is the approach followed by most programs I used, and what we already supported

eo-phi-normalizer/app/Main.hs Outdated Show resolved Hide resolved
pprefs :: ParserPrefs
pprefs = prefs (showHelpOnEmpty <> showHelpOnError)

type Context = (?parserContext :: Optparse.Context)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familiar with many extensions, what does this syntax mean?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ImplicitParams.

I use this extension instead of the ReaderT pattern.

eo-phi-normalizer/app/Main.hs Outdated Show resolved Hide resolved
StructuredJSON
{ input = printTree program'
, output = (printAsProgramOrAsObject <$>) <$> results
}
else do
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too much nesting of ifs leads to higher cognitive load when reading the code. Consider refactoring somehow

Copy link
Member Author

@deemp deemp Feb 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't think 1 nested if is too much.

eo-phi-normalizer/app/Main.hs Show resolved Hide resolved
Comment on lines 32 to 33
- `Dataless formation` - not primitive and does not have attributes bound to primitive formations.
- `⟦ d ↦ ⟦ φ ↦ ξ.ρ.c, ν ↦ ⟦ Δ ⤍ 00- ⟧ ⟧, c ↦ ∅ ⟧`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just to clarify, we mean it does not have immediate attributes bound to primitive formations, but it's ok if its descendants do?
So the formation bound to d would be neither primitive nor dataless, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great if you can add this clarification

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A formation doesn't have non-immediate attributes, does it?

@deemp deemp merged commit 4bd1f12 into master Feb 28, 2024
3 of 6 checks passed
@fizruk fizruk deleted the 147-add-a-command-to-print-metrics-for-a-given-phi-expression branch March 1, 2024 08:55
@fizruk fizruk mentioned this pull request Mar 26, 2024
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.

user-defined-rules.md:46: --> Add a command to print metrics for a given phi expression
3 participants