hgeometry-combinatorial-0.12.0.2: Data structures, and Data types.
Copyright(C) Frank Staals
Licensesee the LICENSE file
MaintainerFrank Staals
Safe HaskellNone
LanguageHaskell2010

Data.UnBounded

Description

Add an unbounded/infintity element to a data type. Essentially, Bottom adds \(-\infty\) (and is pretty much identical to Maybe), whereas Top adds \(\infty\). The UnBounded type adds both.

Synopsis

Documentation

data Top a where Source #

Top a represents the type a, together with a Top element, i.e. an element that is greater than any other element. We can think of `Top a` being defined as:

>>> data Top a = ValT a | Top

Bundled Patterns

pattern ValT :: a -> Top a 
pattern Top :: Top a 

Instances

Instances details
Monad Top Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

return :: a -> Top a #

Functor Top Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

Applicative Top Source # 
Instance details

Defined in Data.UnBounded

Methods

pure :: a -> Top a #

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

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

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

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

Foldable Top Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

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

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

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

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

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

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

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

toList :: Top a -> [a] #

null :: Top a -> Bool #

length :: Top a -> Int #

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

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

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

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

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

Traversable Top Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

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

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

Eq1 Top Source # 
Instance details

Defined in Data.UnBounded

Methods

liftEq :: (a -> b -> Bool) -> Top a -> Top b -> Bool #

Ord1 Top Source # 
Instance details

Defined in Data.UnBounded

Methods

liftCompare :: (a -> b -> Ordering) -> Top a -> Top b -> Ordering #

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

Defined in Data.UnBounded

Methods

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

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

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

Defined in Data.UnBounded

Methods

compare :: Top a -> Top a -> Ordering #

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

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

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

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

max :: Top a -> Top a -> Top a #

min :: Top a -> Top a -> Top a #

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

Defined in Data.UnBounded

Methods

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

show :: Top a -> String #

showList :: [Top a] -> ShowS #

topToMaybe :: Top a -> Maybe a Source #

Top a values are isomorphing to Maybe a values.

_ValT :: Prism (Top a) (Top b) a b Source #

ValT prism. Can be used to access the non-bottom element if it exists:

>>> ValT True & _ValT %~ not
ValT False
>>> Top & _ValT %~ not
Top

_Top :: Prism' (Top a) () Source #

Top prism.

_TopMaybe :: Iso' (Top a) (Maybe a) Source #

Iso between a Top a and a Maybe a, interpreting a Top as a Nothing and vice versa. Note that this reverses the ordering of the elements.

>>> ValT 5 ^. _TopMaybe
Just 5
>>> Just 5 ^.re _TopMaybe
ValT 5
>>> Top ^. _TopMaybe
Nothing
>>> Nothing ^.re _TopMaybe
Top

data Bottom a where Source #

`Bottom a` represents the type a, together with a Bottom element, i.e. an element that is smaller than any other element. We can think of `Bottom a` being defined as:

>>> data Bottom a = Bottom | ValB a

Bundled Patterns

pattern Bottom :: Bottom a 
pattern ValB :: a -> Bottom a 

Instances

Instances details
Monad Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

return :: a -> Bottom a #

Functor Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

Applicative Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

pure :: a -> Bottom a #

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

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

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

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

Foldable Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

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

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

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

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

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

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

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

toList :: Bottom a -> [a] #

null :: Bottom a -> Bool #

length :: Bottom a -> Int #

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

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

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

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

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

Traversable Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

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

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

Eq1 Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

liftEq :: (a -> b -> Bool) -> Bottom a -> Bottom b -> Bool #

Ord1 Bottom Source # 
Instance details

Defined in Data.UnBounded

Methods

liftCompare :: (a -> b -> Ordering) -> Bottom a -> Bottom b -> Ordering #

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

Defined in Data.UnBounded

Methods

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

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

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

Defined in Data.UnBounded

Methods

compare :: Bottom a -> Bottom a -> Ordering #

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

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

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

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

max :: Bottom a -> Bottom a -> Bottom a #

min :: Bottom a -> Bottom a -> Bottom a #

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

Defined in Data.UnBounded

Methods

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

show :: Bottom a -> String #

showList :: [Bottom a] -> ShowS #

bottomToMaybe :: Bottom a -> Maybe a Source #

`Bottom a` values are isomorphing to `Maybe a` values.

_ValB :: Prism (Bottom a) (Bottom b) a b Source #

ValB prism. Can be used to access the non-bottom element if it exists:

>>> ValB True & _ValB %~ not
ValB False
>>> Bottom & _ValB %~ not
Bottom

_BottomMaybe :: Iso' (Bottom a) (Maybe a) Source #

Iso between a 'Bottom a' and a 'Maybe a', interpreting a Bottom as a Nothing and vice versa.

>>> ValB 5 ^. _BottomMaybe
Just 5
>>> Just 5 ^.re _BottomMaybe
ValB 5
>>> Bottom ^. _BottomMaybe
Nothing
>>> Nothing ^.re _BottomMaybe
Bottom

data UnBounded a Source #

`UnBounded a` represents the type a, together with an element MaxInfinity larger than any other element, and an element MinInfinity, smaller than any other element.

Constructors

MinInfinity 
Val 

Fields

MaxInfinity 

Instances

Instances details
Functor UnBounded Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

Foldable UnBounded Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

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

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

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

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

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

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

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

toList :: UnBounded a -> [a] #

null :: UnBounded a -> Bool #

length :: UnBounded a -> Int #

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

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

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

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

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

Traversable UnBounded Source # 
Instance details

Defined in Data.UnBounded

Methods

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

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

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

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

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

Defined in Data.UnBounded

Methods

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

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

Fractional a => Fractional (UnBounded a) Source # 
Instance details

Defined in Data.UnBounded

Num a => Num (UnBounded a) Source # 
Instance details

Defined in Data.UnBounded

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

Defined in Data.UnBounded

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

Defined in Data.UnBounded

_Val :: Prism (UnBounded a) (UnBounded b) a b Source #

Prism to access unbounded value if it exists.

>>> Val True ^? _Val
Just True
>>> MinInfinity ^? _Val :: Maybe Bool
Nothing
>>> Val True & _Val %~ not
Val False
>>> MaxInfinity & _Val %~ not
MaxInfinity

unBoundedToMaybe :: UnBounded a -> Maybe a Source #

Test if an Unbounded is actually bounded.

>>> unBoundedToMaybe (Val 5)
Just 5
>>> unBoundedToMaybe MinInfinity
Nothing
>>> unBoundedToMaybe MaxInfinity
Nothing