| Copyright | (C) Frank Staals |
|---|---|
| License | see the LICENSE file |
| Maintainer | Frank Staals |
| Safe Haskell | None |
| Language | GHC2021 |
HGeometry.Unbounded
Description
Synopsis
- data Top a where
- topToMaybe :: Top a -> Maybe a
- _ValT :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (Top a) (f (Top b))
- _Top :: forall a p f. (Choice p, Applicative f) => p () (f ()) -> p (Top a) (f (Top a))
- _TopMaybe :: forall a p f. (Profunctor p, Functor f) => p (Maybe a) (f (Maybe a)) -> p (Top a) (f (Top a))
- data Bottom a where
- bottomToMaybe :: Bottom a -> Maybe a
- _ValB :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (Bottom a) (f (Bottom b))
- _Bottom :: forall a p f. (Choice p, Applicative f) => p () (f ()) -> p (Bottom a) (f (Bottom a))
- _BottomMaybe :: forall a p f. (Profunctor p, Functor f) => p (Maybe a) (f (Maybe a)) -> p (Bottom a) (f (Bottom a))
- data UnBounded a
- = MinInfinity
- | Val {
- _unUnBounded :: a
- | MaxInfinity
- _Val :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (UnBounded a) (f (UnBounded 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
topToMaybe :: Top a -> Maybe a Source #
Top a values are isomorphing to Maybe a values.
_ValT :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (Top a) (f (Top b)) Source #
ValT prism. Can be used to access the non-bottom element if it exists:
>>>ValT True & _ValT %~ notValT False
>>>Top & _ValT %~ notTop
_Top :: forall a p f. (Choice p, Applicative f) => p () (f ()) -> p (Top a) (f (Top a)) Source #
Top prism.
_TopMaybe :: forall a p f. (Profunctor p, Functor f) => p (Maybe a) (f (Maybe a)) -> p (Top a) (f (Top a)) 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
Instances
bottomToMaybe :: Bottom a -> Maybe a Source #
`Bottom a` values are isomorphing to `Maybe a` values.
_ValB :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (Bottom a) (f (Bottom b)) Source #
ValB prism. Can be used to access the non-bottom element if it exists:
>>>ValB True & _ValB %~ notValB False
>>>Bottom & _ValB %~ notBottom
_Bottom :: forall a p f. (Choice p, Applicative f) => p () (f ()) -> p (Bottom a) (f (Bottom a)) Source #
Bottom prism.
_BottomMaybe :: forall a p f. (Profunctor p, Functor f) => p (Maybe a) (f (Maybe a)) -> p (Bottom a) (f (Bottom a)) Source #
Iso between a 'Bottom a' and a 'Maybe a', interpreting a Bottom as a Nothing and vice versa.
>>>ValB 5 ^. _BottomMaybeJust 5>>>Just 5 ^.re _BottomMaybeValB 5>>>Bottom ^. _BottomMaybeNothing>>>Nothing ^.re _BottomMaybeBottom
`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
_Val :: forall a b p f. (Choice p, Applicative f) => p a (f b) -> p (UnBounded a) (f (UnBounded b)) Source #
Prism to access unbounded value if it exists.
>>>Val True ^? _ValJust True
>>>MinInfinity ^? _Val :: Maybe BoolNothing
>>>Val True & _Val %~ notVal False
>>>MaxInfinity & _Val %~ notMaxInfinity
unBoundedToMaybe :: UnBounded a -> Maybe a Source #
Test if an Unbounded is actually bounded.
>>>unBoundedToMaybe (Val 5)Just 5>>>unBoundedToMaybe MinInfinityNothing>>>unBoundedToMaybe MaxInfinityNothing