Safe Haskell  Safe 

Language  Haskell2010 
AUTHOR
 Dr. Alistair Ward
DESCRIPTION
 A datatype, which represents the permissible range of instances, of the underlying polymorphic datum.
 Designed for use in a polymorphic regexengine, which specifies patterns composed of repeated greedy & nongreedy sequences of Metadata;
* + ? {fewest, most} {fewest,} {fewest} *? +? ?? {fewest, most}? {fewest,}?
 In the context of regexes, this concept is known as Quantification.
 regexes evolved from the minimal ability to optionally qualify the datum with a https://en.wikipedia.org/wiki/Kleene_star suffix.
More exotic repetitionspecifications could be composed by concatenating these atomic buildingblocks.
Here, I've taken the contrary topdown view, & assumed that all data are qualified by a full
RepetitionBounds
, which in most cases will degenerate into a simpler form.  The type of entity which is being repeated, isn't the domain of this datatype; it's polymorphic.
 type Repetitions = Int
 type RepetitionBounds = (Repetitions, Maybe Repetitions)
 data Repeatable a = MkRepeatable {
 base :: a
 repetitionBounds :: RepetitionBounds
 isGreedy :: Bool
 oneOrMoreToken :: Char
 rangeDelimiters :: (Char, Char)
 rangeSeparatorToken :: Char
 tokens :: String
 zeroOrMoreToken :: Char
 zeroOrOneToken :: Char
 one :: a > Repeatable a
 oneOrMore :: a > Repeatable a
 oneOrMore' :: a > Repeatable a
 zeroOrMore :: a > Repeatable a
 zeroOrMore' :: a > Repeatable a
 zeroOrOne :: a > Repeatable a
 zeroOrOne' :: a > Repeatable a
 repeatableParser :: a > Parser (Repeatable a)
 showSuffix :: Repeatable a > ShowS
 getFewest :: Repeatable a > Repetitions
 getMost :: Repeatable a > Maybe Repetitions
 focus :: Repeatable a > Repetitions > Repeatable a
 toSingleton :: Repeatable a > Repeatable a
 (^#>#) :: a > RepetitionBounds > Repeatable a
 (^#>#?) :: a > RepetitionBounds > Repeatable a
 (^#>) :: a > Repetitions > Repeatable a
 (^#>?) :: a > Repetitions > Repeatable a
 (^#) :: a > Repetitions > Repeatable a
 isPrecise :: Repeatable a > Bool
 hasPreciseBounds :: RepetitionBounds > Bool
Types
Typesynonyms
type Repetitions = Int Source #
A number of repetitions.
type RepetitionBounds = (Repetitions, Maybe Repetitions) Source #
Defines the bounds of a range of permissible repetitions.
Datatypes
data Repeatable a Source #
Declares a polymorphic datatype, which augments the underlying base
datum, with the range of times it may be used.
MkRepeatable  

Functor Repeatable Source #  
Eq a => Eq (Repeatable a) Source #  
Read a => Read (Repeatable a) Source #  
Show a => Show (Repeatable a) Source #  
NFData a => NFData (Repeatable a) Source #  
SelfValidator a => SelfValidator (Repeatable a) Source #  
Consumer a => Consumer (Repeatable a) Source #  
Constants
rangeSeparatorToken :: Char Source #
The token used to separate RepetitionBounds
, when in the String
form.
zeroOrMoreToken :: Char Source #
 The token used to denote
zeroOrMore
, when in theString
form.  AKA Kleene Star.
Functions
one :: a > Repeatable a Source #
 Construct a
Repeatable
, tailored for unrepeated data.  A degenerate case of
^#
.
oneOrMore :: a > Repeatable a Source #
 Construct a greedy
Repeatable
, from a polymorphic datum, with lowerRepetitionBounds
== one.  A specific case of
^#>
.
oneOrMore' :: a > Repeatable a Source #
Construct a nongreedy version of oneOrMore
.
zeroOrMore :: a > Repeatable a Source #
 Construct a greedy
Repeatable
, from a polymorphic datum, withfewest
== 0.  A specific case of
^#>
.
zeroOrMore' :: a > Repeatable a Source #
Construct a nongreedy version of zeroOrMore
.
zeroOrOne :: a > Repeatable a Source #
 Construct a greedy
Repeatable
, from a polymorphic datum, withfewest
== 0 &most
== 1.  A specific case of
^#>#
.
zeroOrOne' :: a > Repeatable a Source #
Construct a nongreedy version of zeroOrOne
.
repeatableParser :: a > Parser (Repeatable a) Source #
Builds a parser for a specification of the number of permissible instances of the specified polymorphic parameter.
showSuffix :: Repeatable a > ShowS Source #
Accessors
getFewest :: Repeatable a > Repetitions Source #
Accessor.
getMost :: Repeatable a > Maybe Repetitions Source #
Accessor.
Mutators
focus :: Repeatable a > Repetitions > Repeatable a Source #
Reduces a Repeatable
, with a range of RepetitionBounds
, to a precise number of repetitions.
toSingleton :: Repeatable a > Repeatable a Source #
 Reduces a
Repeatable
, with a range ofRepetitionBounds
, to a singleton.  A degenerate case of
focus
.
Operators
:: a  The polymorphic payload from which to construct the 
> RepetitionBounds  The permissible repetitionbounds for the polymorphic data. 
> Repeatable a 
 Construct a greedy
Repeatable
, from a polymorphic datum, with the specified range of permissible instances.  The #s in the identifier represent the two bounds.
 a{f, m}
:: a  The polymorphic payload from which to construct the 
> RepetitionBounds  The permissible repetitionbounds for the polymorphic data. 
> Repeatable a 
 Construct a nongreedy version of
^#>#
.  a{f, m}?
:: a  The polymorphic payload from which to construct the 
> Repetitions  The minimum permissible repetitions of the polymorphic data. 
> Repeatable a 
 Construct a greedy
Repeatable
, tailored for data repeated at least the specified number of times.  The # in the identifier represents the single bound.
 a{f,}
:: a  The polymorphic payload from which to construct the 
> Repetitions  The minimum permissible repetitions of the polymorphic data. 
> Repeatable a 
 Construct a nongreedy version of
^#>
.  a{f,}?
:: a  The polymorphic payload from which to construct the 
> Repetitions  The precise number of repetitions of the polymorphic data which is required. 
> Repeatable a 
 Construct a
Repeatable
, tailored for data repeated a precise number of times.  The # in the identifier represents the single bound.
 a{f}
Predicates
isPrecise :: Repeatable a > Bool Source #
True if there's no choice in the number of repetitions; implemented via isPrecise
.
hasPreciseBounds :: RepetitionBounds > Bool Source #
Predicate which is True
if exactly one value is permissible, ie lower & upper bounds on the number of Repetitions
are identical.