rg-1.3.0.0: A dynamic/unbounded alternative to Bounded Enum

Safe HaskellNone
LanguageHaskell2010

Data.Rg

Synopsis

Documentation

class Rg rg where Source #

Rg acts a bit like a Bounded Enum, but the size of the enumeration can be dynamically determined from each value in the type (see sizeRg)

Minimal complete definition

sizeRg, toRg, fromRg | rgCoreMethods

Methods

sizeRg :: rg -> Int Source #

the number of values in the enumeration; sizeRg sz > 0

toRg :: rg -> Int -> Maybe rg Source #

the nth item in the enumeration (first is 0)

fromRg :: rg -> Int Source #

place in the enumation (first is 0)

rgCoreMethods :: RgCoreMethods rg Source #

an alternative way of specifying sizeRg, toRg and fromRg

minRg :: rg -> rg Source #

first item in the enumeration

maxRg :: rg -> rg Source #

last item in the enumeration

succRg :: rg -> Maybe rg Source #

next item in the enumeration (Nothing if already last)

predRg :: rg -> Maybe rg Source #

previous item in the enumeration (Nothing if already first)

allListRg :: rg -> [rg] Source #

list given items in the enumeration

listRg :: rg -> [Int] -> [rg] Source #

list given items in the enumeration, stopping as soon as an index is out of range

allVectorRg :: rg -> [rg] Source #

list given items in the enumeration as a Vector

vectorRg :: rg -> [Int] -> Vector rg Source #

list the items in the enumeration as a Vector, stopping as soon as an index is out of range

Instances
Rg (Range a) Source # 
Instance details

Defined in Data.Rg

(Bounded i, Enum i) => Rg (BE i) Source # 
Instance details

Defined in Data.Rg

Methods

sizeRg :: BE i -> Int Source #

toRg :: BE i -> Int -> Maybe (BE i) Source #

fromRg :: BE i -> Int Source #

rgCoreMethods :: RgCoreMethods (BE i) Source #

minRg :: BE i -> BE i Source #

maxRg :: BE i -> BE i Source #

succRg :: BE i -> Maybe (BE i) Source #

predRg :: BE i -> Maybe (BE i) Source #

allListRg :: BE i -> [BE i] Source #

listRg :: BE i -> [Int] -> [BE i] Source #

allVectorRg :: BE i -> [BE i] Source #

vectorRg :: BE i -> [Int] -> Vector (BE i) Source #

data RgCoreMethods rg Source #

dynamically encapsulates the core Rg methods

rgCoreMethodsBE :: forall rg. (Bounded rg, Enum rg) => RgCoreMethods rg Source #

if you want to create an Rg from a Bounded Enum you can bind rgCoreMethods to this function

class (Rg e, Buildable e, Eq e, Ord e, Show e) => RgText e where Source #

a class in which we can build things and parse them from Text

Minimal complete definition

Nothing

Methods

parseRgText :: e -> Text -> Possibly e Source #

newtype BE a Source #

a newtype wrapper used for deriving Rg instances from Bounded Enum

Constructors

BE 

Fields

Instances
Bounded a => Bounded (BE a) Source # 
Instance details

Defined in Data.Rg

Methods

minBound :: BE a #

maxBound :: BE a #

Enum a => Enum (BE a) Source # 
Instance details

Defined in Data.Rg

Methods

succ :: BE a -> BE a #

pred :: BE a -> BE a #

toEnum :: Int -> BE a #

fromEnum :: BE a -> Int #

enumFrom :: BE a -> [BE a] #

enumFromThen :: BE a -> BE a -> [BE a] #

enumFromTo :: BE a -> BE a -> [BE a] #

enumFromThenTo :: BE a -> BE a -> BE a -> [BE a] #

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

Defined in Data.Rg

Methods

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

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

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

Defined in Data.Rg

Methods

compare :: BE a -> BE a -> Ordering #

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

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

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

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

max :: BE a -> BE a -> BE a #

min :: BE a -> BE a -> BE a #

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

Defined in Data.Rg

Methods

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

show :: BE a -> String #

showList :: [BE a] -> ShowS #

(Bounded i, Enum i) => Rg (BE i) Source # 
Instance details

Defined in Data.Rg

Methods

sizeRg :: BE i -> Int Source #

toRg :: BE i -> Int -> Maybe (BE i) Source #

fromRg :: BE i -> Int Source #

rgCoreMethods :: RgCoreMethods (BE i) Source #

minRg :: BE i -> BE i Source #

maxRg :: BE i -> BE i Source #

succRg :: BE i -> Maybe (BE i) Source #

predRg :: BE i -> Maybe (BE i) Source #

allListRg :: BE i -> [BE i] Source #

listRg :: BE i -> [Int] -> [BE i] Source #

allVectorRg :: BE i -> [BE i] Source #

vectorRg :: BE i -> [Int] -> Vector (BE i) Source #

data Range a Source #

used to generate Rg values from lists of things

Instances
Show a => Show (Range a) Source # 
Instance details

Defined in Data.Rg

Methods

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

show :: Range a -> String #

showList :: [Range a] -> ShowS #

Rg (Range a) Source # 
Instance details

Defined in Data.Rg

newStartOfRangeFromList :: [a] -> Range a Source #

generating a Range from a list

extractRange :: Range a -> a Source #

extracting the thing