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

Add support for deriving ToExpr from Show #94

Closed

Conversation

Gabriella439
Copy link

I didn't really change the ToExpr class, but this adds two useful functions that allow one to implement a ToExpr instance if a type already has a Show instance.

I didn't really change the `ToExpr` class, but this adds two useful
functions that allow one to implement a `ToExpr` instance if a type
already has a `Show` instance.
-}
showToExpr :: Show a => a -> Either ShowParseFailed Expr
showToExpr a =
case Parsec.parse exprParser "" (show a) of
Copy link
Collaborator

@phadej phadej Aug 31, 2024

Choose a reason for hiding this comment

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

This doesn't work. exprParser is not parser for Haskell expressions. Close syntax, but not the same.

EDIT: In particular infix operators are something which is not accepted by exprParser.

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