Skip to content

Conversation

@david-christiansen
Copy link
Contributor

Fixes #90.

---

A [view pattern](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/view_patterns.html) allows pattern matching on the result of a function.
While most patterns share syntax with the corresponding expressions, there is no expression counterpart to view patterns.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
While most patterns share syntax with the corresponding expressions, there is no expression counterpart to view patterns.
While most view patterns look like expressions, they can *only* be used as patterns. Sometimes GHC will think you've tried to use a pattern where it expected an expression, which is when this error arises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that this edit results in a true statement. View patterns don't look like expressions, because they contain ->. Though I suppose this error could occur if a \ were omitted.

Copy link
Member

Choose a reason for hiding this comment

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

"patterns share syntax with the corresponding expressions" sounded like a complicated way of saying "patterns look like expressions", but perhaps it is not as precise. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That part makes sense. The key here, though, is that view patterns in particular do not share syntax with the expression fragment of the language, as -> is not a valid infix operator. I'll tweak the phrasing.

Copy link
Member

@chreekat chreekat left a comment

Choose a reason for hiding this comment

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

Thanks! The new phrasing makes sense to me.

@david-christiansen david-christiansen merged commit 346a33d into main Oct 24, 2022
@david-christiansen david-christiansen deleted the GHC-66228 branch October 24, 2022 10:19
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.

PsErrViewPatInExpr -> 66228

3 participants