-
Notifications
You must be signed in to change notification settings - Fork 2
Add Elem type family and ElemSym data type #4
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
Conversation
Note, I did not test this.
| type family Elem where | ||
| Elem (_:xs) x = Elem xs x | ||
| Elem '[] _ = 'False | ||
| Elem (x':_) x = 'True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above two equations match both x:xs and [] cases, so this equation will never be reached. Also, did you intend to assert that x' and x are equivalent? In which case, it should be Elem (x:_) x = True.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant to do `Elem (x ': xs) x = 'True
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahhh, of course. I tend to avoid ticked promoted constructors except where required to disambiguate. Further reading: https://gitlab.haskell.org/ghc/ghc/-/issues/20531
|
Thanks for this. I think this character predicate better fits with other parsers, which I hadn't implemented yet. I've done so at #5 : type OneOf :: [Char] -> PParser Char
type OneOf chs = Satisfy (ElemSym chs)So now you can say: type ParseOperator = OneOf ['+', '-', '/', '*'] |
|
I'm considering this implemented. Note that I don't actually export my |
I was also thinking of a |
|
I will gladly accept contributions. Can a Chromebook not run GHC? (GHC supports ARM64.) |
Note, I did not test this.