rere-0.2: Regular-expressions extended with fixpoints for context-free powers
Safe HaskellSafe
LanguageHaskell2010

RERE.Type

Description

Regular-expression with fixed points.

Synopsis

Regular expression type

data RE a Source #

Regular expression with fixed point.

Constructors

Null 
Full 
Eps 
Ch CharSet 
App (RE a) (RE a) 
Alt (RE a) (RE a) 
Star (RE a) 
Var a 
Let Name (RE a) (RE (Var a)) 
Fix Name (RE (Var a)) 

Instances

Instances details
Monad RE Source # 
Instance details

Defined in RERE.Type

Methods

(>>=) :: RE a -> (a -> RE b) -> RE b #

(>>) :: RE a -> RE b -> RE b #

return :: a -> RE a #

Functor RE Source # 
Instance details

Defined in RERE.Type

Methods

fmap :: (a -> b) -> RE a -> RE b #

(<$) :: a -> RE b -> RE a #

Applicative RE Source # 
Instance details

Defined in RERE.Type

Methods

pure :: a -> RE a #

(<*>) :: RE (a -> b) -> RE a -> RE b #

liftA2 :: (a -> b -> c) -> RE a -> RE b -> RE c #

(*>) :: RE a -> RE b -> RE b #

(<*) :: RE a -> RE b -> RE a #

Foldable RE Source # 
Instance details

Defined in RERE.Type

Methods

fold :: Monoid m => RE m -> m #

foldMap :: Monoid m => (a -> m) -> RE a -> m #

foldMap' :: Monoid m => (a -> m) -> RE a -> m #

foldr :: (a -> b -> b) -> b -> RE a -> b #

foldr' :: (a -> b -> b) -> b -> RE a -> b #

foldl :: (b -> a -> b) -> b -> RE a -> b #

foldl' :: (b -> a -> b) -> b -> RE a -> b #

foldr1 :: (a -> a -> a) -> RE a -> a #

foldl1 :: (a -> a -> a) -> RE a -> a #

toList :: RE a -> [a] #

null :: RE a -> Bool #

length :: RE a -> Int #

elem :: Eq a => a -> RE a -> Bool #

maximum :: Ord a => RE a -> a #

minimum :: Ord a => RE a -> a #

sum :: Num a => RE a -> a #

product :: Num a => RE a -> a #

Traversable RE Source # 
Instance details

Defined in RERE.Type

Methods

traverse :: Applicative f => (a -> f b) -> RE a -> f (RE b) #

sequenceA :: Applicative f => RE (f a) -> f (RE a) #

mapM :: Monad m => (a -> m b) -> RE a -> m (RE b) #

sequence :: Monad m => RE (m a) -> m (RE a) #

Eq a => Eq (RE a) Source # 
Instance details

Defined in RERE.Type

Methods

(==) :: RE a -> RE a -> Bool #

(/=) :: RE a -> RE a -> Bool #

Ord a => Ord (RE a) Source # 
Instance details

Defined in RERE.Type

Methods

compare :: RE a -> RE a -> Ordering #

(<) :: RE a -> RE a -> Bool #

(<=) :: RE a -> RE a -> Bool #

(>) :: RE a -> RE a -> Bool #

(>=) :: RE a -> RE a -> Bool #

max :: RE a -> RE a -> RE a #

min :: RE a -> RE a -> RE a #

Show a => Show (RE a) Source # 
Instance details

Defined in RERE.Type

Methods

showsPrec :: Int -> RE a -> ShowS #

show :: RE a -> String #

showList :: [RE a] -> ShowS #

Ord a => IsString (RE a) Source # 
Instance details

Defined in RERE.Type

Methods

fromString :: String -> RE a #

Ord a => Semigroup (RE a) Source # 
Instance details

Defined in RERE.Type

Methods

(<>) :: RE a -> RE a -> RE a #

sconcat :: NonEmpty (RE a) -> RE a #

stimes :: Integral b => b -> RE a -> RE a #

(Absurd a, Ord a) => Arbitrary (RE a) Source # 
Instance details

Defined in RERE.Type

Methods

arbitrary :: Gen (RE a) #

shrink :: RE a -> [RE a] #

Smart constructors

ch_ :: Char -> RE a Source #

Smart Ch, as it takes Char argument.

(\/) :: Ord a => RE a -> RE a -> RE a infixl 5 Source #

Smart Alt.

star_ :: RE a -> RE a Source #

Smart Star.

let_ :: Ord a => Name -> RE a -> RE (Var a) -> RE a Source #

Smart Let

fix_ :: Ord a => Name -> RE (Var a) -> RE a Source #

Smart Fix.

(>>>=) :: Ord b => RE a -> (a -> RE b) -> RE b infixl 4 Source #

Variable substitution.

string_ :: Ord a => String -> RE a Source #

Construct literal String regex.

Operations

nullable :: RE a -> Bool Source #

Whether the regular expression accepts empty string, or whether the formal language contains empty string.

>>> nullable Eps
True
>>> nullable (ch_ 'c')
False

derivative :: Char -> RE Void -> RE Void Source #

Derivative of regular exression to respect of character. derivative c r is \(D_c(r)\).

match :: RE Void -> String -> Bool Source #

Match string by iteratively differentiating the regular expression.

This version is slow, consider using matchR.

compact :: Ord a => RE a -> RE a Source #

Re-apply smart constructors on RE structure, thus potentially making it smaller.

This function is slow.

size :: RE a -> Int Source #

Size of RE. Counts constructors.

Internals

derivative1 :: Char -> RE Void -> RE Void Source #

derivative1 and derivative2 are slightly different implementations internally. We are interested in comparing whether either one is noticeably faster (no).

derivative2 :: Char -> RE Void -> RE Void Source #

derivative1 and derivative2 are slightly different implementations internally. We are interested in comparing whether either one is noticeably faster (no).