Text.Lexer: add `non`, a kind of lexer negation
`non` takes a sub-lexer as an argument and will recognise any
character if the sub-lexer fails, or fail if the sub-lexer succeeds.
commit8c6a569e41f62c675ad074df70ab8df226874a67
authorMichael Morgan <morgan.michael@me.com>
dateThu 31 Aug 2017, 05:51 (9 years ago)
parent2df69e8
libs/contrib/Text/Lexer.idr+4
@@ -101,6 +101,10 @@ export
101101any : Lexer
102102any = Pred (const True)
103103
104+||| Recognise any character if the sub-lexer `l` fails.
105+non : (l : Lexer) -> Lexer
106+non l = reject l <+> any
107+
104108||| Recognise no input (doesn't consume any input)
105109export
106110empty : Recognise False