Add Elem type family and ElemSym data type#4
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.
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.
I meant to do `Elem (x ': xs) x = 'True
There was a problem hiding this comment.
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.