| Stability | experimental |
|---|---|
| Maintainer | Roman Cheplyaka <roma@ro-che.info> |
Text.Regex.Applicative
Description
Documentation
Type of regular expressions that recognize symbols of type s and
produce a result of type a.
Regular expressions can be built using Functor, Applicative and
Alternative instances in the following natural way:
-
f<$>ramatches ifframatches, and its return value is the result of applyingfto the return value ofra. -
purexmatches the empty string (i.e. it does not consume any symbols), and its return value isx -
rf<*>ramatches a string iff it is a concatenation of two strings: one matched byrfand the other matched byra. The return value isf a, wherefandaare the return values ofrfandrarespectively. -
ra<|>rbmatches a string which is accepted by eitherraorrb. It is left-biased, so if both can match, the result ofrais used. -
emptyis a regular expression which does not match any string. -
manyramatches concatenation of zero or more strings matched byraand returns the list ofra's return values on those strings.
Instances
| Functor (RE s) | |
| Applicative (RE s) | |
| Alternative (RE s) |
psym :: (s -> Bool) -> RE s sSource
Matches and returns a single symbol which satisfies the predicate
reFoldl :: (b -> a -> b) -> b -> RE s a -> RE s bSource
Greedily matches zero or more symbols, which are combined using the given folding function
(=~) :: [s] -> RE s a -> Maybe aSource
Attempts to match a string of symbols against the regular expression
module Control.Applicative