charset-0.3.9: Fast unicode character sets based on complemented PATRICIA tries
Copyright(c) Edward Kmett 2010-2011
LicenseBSD3
Maintainerekmett@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellTrustworthy
LanguageHaskell2010

Data.CharSet

Description

A CharSet is an efficient representation of a set of Lexeme values designed for fast membership tests.

As an example build isAlpha will create a set of alphabetic characters. We can then use member on the generated set to efficiently test if a given Char represents an alphabetic character.

Designed to be imported qualified:

import Data.CharSet (CharSet)
import qualified Data.CharSet as CharSet
Synopsis

Set type

data CharSet Source #

Stored as a (possibly negated) IntSet and a fast set used for the head byte.

The set of valid (possibly negated) head bytes is stored unboxed as a 32-byte bytestring-based lookup table.

Constructors

CharSet !Bool !ByteSet !IntSet 

Instances

Instances details
Data CharSet Source # 
Instance details

Defined in Data.CharSet

Methods

gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> CharSet -> c CharSet

gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c CharSet

toConstr :: CharSet -> Constr

dataTypeOf :: CharSet -> DataType

dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c CharSet)

dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c CharSet)

gmapT :: (forall b. Data b => b -> b) -> CharSet -> CharSet

gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> CharSet -> r

gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> CharSet -> r

gmapQ :: (forall d. Data d => d -> u) -> CharSet -> [u]

gmapQi :: Int -> (forall d. Data d => d -> u) -> CharSet -> u

gmapM :: Monad m => (forall d. Data d => d -> m d) -> CharSet -> m CharSet

gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> CharSet -> m CharSet

gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> CharSet -> m CharSet

IsString CharSet Source #
= CharSet.fromList
Instance details

Defined in Data.CharSet

Methods

fromString :: String -> CharSet

Monoid CharSet Source # 
Instance details

Defined in Data.CharSet

Semigroup CharSet Source # 
Instance details

Defined in Data.CharSet

Methods

(<>) :: CharSet -> CharSet -> CharSet

sconcat :: NonEmpty CharSet -> CharSet

stimes :: Integral b => b -> CharSet -> CharSet

Bounded CharSet Source # 
Instance details

Defined in Data.CharSet

Read CharSet Source # 
Instance details

Defined in Data.CharSet

Methods

readsPrec :: Int -> ReadS CharSet

readList :: ReadS [CharSet]

readPrec :: ReadPrec CharSet

readListPrec :: ReadPrec [CharSet]

Show CharSet Source # 
Instance details

Defined in Data.CharSet

Methods

showsPrec :: Int -> CharSet -> ShowS

show :: CharSet -> String

showList :: [CharSet] -> ShowS

Eq CharSet Source # 
Instance details

Defined in Data.CharSet

Methods

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

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

Ord CharSet Source # 
Instance details

Defined in Data.CharSet

Methods

compare :: CharSet -> CharSet -> Ordering

(<) :: CharSet -> CharSet -> Bool

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

(>) :: CharSet -> CharSet -> Bool

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

max :: CharSet -> CharSet -> CharSet

min :: CharSet -> CharSet -> CharSet

Operators

Query

null :: CharSet -> Bool Source #

O(n) worst case

size :: CharSet -> Int Source #

O(n)

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

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

Construction

build :: (Char -> Bool) -> CharSet Source #

Applies a predicate across the whole range of possible character values to create a set of only those characters which satisfy the predicate.

As an example build isAlpha will generate a CharSet of all alphabetic characters.

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

delete :: Char -> CharSet -> CharSet Source #

range :: Char -> Char -> CharSet Source #

Combine

Filter

filter :: (Char -> Bool) -> CharSet -> CharSet Source #

partition :: (Char -> Bool) -> CharSet -> (CharSet, CharSet) Source #

Map

map :: (Char -> Char) -> CharSet -> CharSet Source #

Fold

fold :: (Char -> b -> b) -> b -> CharSet -> b Source #

Conversion

List

toList :: CharSet -> String Source #

fromList :: String -> CharSet Source #

Ordered list

toAscList :: CharSet -> String Source #

IntMaps

fromCharSet :: CharSet -> (Bool, IntSet) Source #

toCharSet :: IntSet -> CharSet Source #

Array

toArray :: CharSet -> UArray Char Bool Source #