rere-0.1: Regular-expressions extended with fixpoints for context-free powers

Safe HaskellSafe
LanguageHaskell2010

RERE.CharSet

Contents

Description

Sets of characters.

Using this is more efficint than Alt:ng individual characters.

Synopsis

Set of characters

data CharSet Source #

A set of Chars.

We use range set, which works great with Char.

Instances
Eq CharSet Source # 
Instance details

Defined in RERE.CharSet

Methods

(==) :: CharSet -> CharSet -> Bool #

(/=) :: CharSet -> CharSet -> Bool #

Ord CharSet Source # 
Instance details

Defined in RERE.CharSet

Show CharSet Source # 
Instance details

Defined in RERE.CharSet

IsString CharSet Source #
>>> "foobar" :: CharSet
"abfor"
Instance details

Defined in RERE.CharSet

Methods

fromString :: String -> CharSet #

Construction

empty :: CharSet Source #

Empty character set.

universe :: CharSet Source #

universe

>>> size universe
1114112
>>> universe
CS.fromIntervalList [('\NUL','\1114111')]

singleton :: Char -> CharSet Source #

Singleton character set.

insert :: Char -> CharSet -> CharSet Source #

Insert Char into CharSet.

union :: CharSet -> CharSet -> CharSet Source #

Union of two CharSets.

intersection :: CharSet -> CharSet -> CharSet Source #

Intersection of two CharSets

complement :: CharSet -> CharSet Source #

Complement of a CharSet

difference :: CharSet -> CharSet -> CharSet Source #

Difference of two CharSets.

Query

size :: CharSet -> Int Source #

Size of CharSet

>>> size $ fromIntervalList [('a','f'), ('0','9')]
16
>>> length $ toList $ fromIntervalList [('a','f'), ('0','9')]
16

null :: CharSet -> Bool Source #

Check whether CharSet is empty.

member :: Char -> CharSet -> Bool Source #

Test whether character is in the set.

Conversions

fromList :: String -> CharSet Source #

Make CharSet from a list of characters, i.e. String.

toList :: CharSet -> String Source #

Convert CharSet to a list of characters i.e. String.

fromIntervalList :: [(Char, Char)] -> CharSet Source #

Convert from interval pairs.

>>> fromIntervalList []
""
>>> fromIntervalList [('a','f'), ('0','9')]
"0123456789abcdef"
>>> fromIntervalList [('Z','A')]
""

toIntervalList :: CharSet -> [(Char, Char)] Source #

Convert to interval list

>>> toIntervalList $ union "01234" "56789"
[('0','9')]