Skip to content

Show the parenthesized version of an expression #3036

Closed
@asarkar

Description

@asarkar

Is your feature request related to a problem? Please describe.

The expression:

lexeme $ (:) <$> between '2' '9' <*> M.count 2 $ between '0' '9'

is evaluated as:

lexeme (((:) <$> between '2' '9' <*> M.count 2) (between '0' '9'))

because $ has lower precedence than <$> and <*>.

The intent is for the expression to be evaluated as:

lexeme $ (:) <$> between '2' '9' <*> M.count 2 (between '0' '9')

Describe the solution you'd like

To avoid these kind of errors, it will be very helpful to be able to see the parenthesized version of an expression.

Describe alternatives you've considered

An alternative is to aggressively parenthesize everything. That won't look pretty.
Another is to look up the precedence of each operator used in the expression. It can be time consuming for a complex expression.

Additional context
Originally discussed in this Reddit thread.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions