Copyright | (C) Frank Staals |
---|---|
License | see the LICENSE file |
Maintainer | Frank Staals |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- data Top a where
- topToMaybe :: Top a -> Maybe a
- _ValT :: Prism (Top a) (Top b) a b
- _Top :: Prism' (Top a) ()
- _TopMaybe :: Iso' (Top a) (Maybe a)
- data Bottom a where
- bottomToMaybe :: Bottom a -> Maybe a
- _ValB :: Prism (Bottom a) (Bottom b) a b
- _Bottom :: Prism' (Bottom a) ()
- _BottomMaybe :: Iso' (Bottom a) (Maybe a)
- data UnBounded a
- = MinInfinity
- | Val {
- _unUnBounded :: a
- | MaxInfinity
- _Val :: Prism (UnBounded a) (UnBounded b) a b
- unBoundedToMaybe :: UnBounded a -> Maybe a
Documentation
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
Instances
Monad Top Source # | |
Functor Top Source # | |
Applicative Top Source # | |
Foldable Top Source # | |
Defined in Data.UnBounded 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 # elem :: Eq a => a -> Top a -> Bool # maximum :: Ord a => Top a -> a # | |
Traversable Top Source # | |
Eq1 Top Source # | |
Ord1 Top Source # | |
Defined in Data.UnBounded | |
Eq a => Eq (Top a) Source # | |
Ord a => Ord (Top a) Source # | |
Show a => Show (Top a) Source # | |
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
`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
Instances
Monad Bottom Source # | |
Functor Bottom Source # | |
Applicative Bottom Source # | |
Foldable Bottom Source # | |
Defined in Data.UnBounded 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 # elem :: Eq a => a -> Bottom a -> Bool # maximum :: Ord a => Bottom a -> a # minimum :: Ord a => Bottom a -> a # | |
Traversable Bottom Source # | |
Eq1 Bottom Source # | |
Ord1 Bottom Source # | |
Defined in Data.UnBounded | |
Eq a => Eq (Bottom a) Source # | |
Ord a => Ord (Bottom a) Source # | |
Defined in Data.UnBounded | |
Show a => Show (Bottom a) Source # | |
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
`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.
Instances
_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