Repository navigation
Incorporating negative integers into patterns - #43
Merged
Merged
Conversation
hshkk
commented
Nov 24, 2026
Comment on lines
+179
to
+180
| (Just ("Unexpected '" <> bad <> "'")) | ||
| (underline file (pos +> Text.length bad) "not sure how to interpret this symbol") |
Owner
Author
There was a problem hiding this comment.
The message for lexical errors was slightly revised.
Owner
Author
There was a problem hiding this comment.
The placement of these errors might be revised once we implement errors more properly.
hshkk
commented
Nov 24, 2026
Comment on lines
+112
to
+114
| PatCon :: { L LHsPat } | ||
| : '-' int { pneg $1 $2 } | ||
|
|
Owner
Author
There was a problem hiding this comment.
The main addition is a PatCon nonterminal that is subordinate to Pat, but greater in precedence over PatAtom. PatCon contains pattern constructors (added by D) and negation patterns (added by B, as seen here).
leoSallos
approved these changes
Nov 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request intends to close Issue #42. For a description of the issue, please refer to that link.
Some tests were added to verify that the issue is truly gone. Now, the parser (assuming at least
L B) accepts definitions like the following.The resulting abstract syntax tree is as follows. Note the lack of a
LHsPNegconstructor like I implied in Issue #42, since we actually don't want something that general. For instance,(- x)is not a valid pattern in Haskell.fromList [ LHsSig "fun" (LHsTyFn (LHsTyList (LHsTyCon "Int" (fromList []))) (LHsTyList (LHsTyCon "Int" (fromList [])))) , LHsEqn "fun" (fromList [LHsPListCons (LHsPInt (-1)) LHsPWild]) (LHsList (fromList [LHsNeg (LHsInt 1)])) , LHsEqn "fun" (fromList [LHsPVar "xs"]) (LHsList (fromList [])) ]