| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Kleene.Functor
Synopsis
- data K c a
- data Greediness
- few :: K c a -> K c [a]
- anyChar :: (Ord c, Enum c, Bounded c) => K c c
- oneof :: (Ord c, Enum c, Foldable f) => f c -> K c c
- char :: (Ord c, Enum c) => c -> K c c
- charRange :: (Enum c, Ord c) => c -> c -> K c c
- dot :: K Char Char
- everything :: (Ord c, Enum c, Bounded c) => K c [c]
- everything1 :: (Ord c, Enum c, Bounded c) => K c [c]
- isEmpty :: (Ord c, Enum c, Bounded c) => K c a -> Bool
- isEverything :: (Ord c, Enum c, Bounded c) => K c a -> Bool
- match :: K c a -> [c] -> Maybe a
- toRE :: (Ord c, Enum c, Bounded c) => K c a -> RE c
- toKleene :: FiniteKleene c k => K c a -> k
- fromRE :: (Ord c, Enum c) => RE c -> K c [c]
- toRA :: K c a -> RE c a
Documentation
Applicative Functor regular expression.
Instances
| Functor (K c) Source # | |
| Applicative (K c) Source # | |
| Alternative (K c) Source # | |
| Alt (K c) Source # | |
| Apply (K c) Source # | |
| (c ~ Char, IsString a) => IsString (K c a) Source # | |
Defined in Kleene.Internal.Functor Methods fromString :: String -> K c a # | |
| c ~ Char => Pretty (K c a) Source # | Convert to non-matching JavaScript string which can be used
as an argument to
|
data Greediness Source #
Star behaviour
Instances
Constructors
few :: K c a -> K c [a] Source #
Let's define two similar regexps
>>>let re1 = liftA2 (,) (few $ char 'a') (many $ char 'a')>>>let re2 = liftA2 (,) (many $ char 'a') (few $ char 'a')
Their RE behaviour is the same:
>>>C.equivalent (toRE re1) (toRE re2)True
>>>map (C.match $ toRE re1) ["aaa","bbb"][True,False]
However, the RA behaviour is different!
>>>R.match (toRA re1) "aaaa"Just ("","aaaa")
>>>R.match (toRA re2) "aaaa"Just ("aaaa","")
oneof :: (Ord c, Enum c, Foldable f) => f c -> K c c Source #
>>>putPretty $ oneof ("foobar" :: [Char])^[a-bfor]$
Queries
Matching
Conversions
toRE :: (Ord c, Enum c, Bounded c) => K c a -> RE c Source #
Convert to RE.
>>>putPretty (toRE $ many "foo" :: RE.RE Char)^(foo)*$
toKleene :: FiniteKleene c k => K c a -> k Source #
Convert to any Kleene