nat-optics-1.0.1.0: Refinement types for natural numbers with an optics interface
Safe HaskellTrustworthy
LanguageHaskell2010

NatOptics.Positive

Synopsis

Type constructor

data Positive number Source #

Instances

Instances details
Eq number => Eq (Positive number) Source # 
Instance details

Defined in NatOptics.Positive.Unsafe

Methods

(==) :: Positive number -> Positive number -> Bool #

(/=) :: Positive number -> Positive number -> Bool #

Ord number => Ord (Positive number) Source # 
Instance details

Defined in NatOptics.Positive.Unsafe

Methods

compare :: Positive number -> Positive number -> Ordering #

(<) :: Positive number -> Positive number -> Bool #

(<=) :: Positive number -> Positive number -> Bool #

(>) :: Positive number -> Positive number -> Bool #

(>=) :: Positive number -> Positive number -> Bool #

max :: Positive number -> Positive number -> Positive number #

min :: Positive number -> Positive number -> Positive number #

Show number => Show (Positive number) Source # 
Instance details

Defined in NatOptics.Positive.Unsafe

Methods

showsPrec :: Int -> Positive number -> ShowS #

show :: Positive number -> String #

showList :: [Positive number] -> ShowS #

Optics

refine :: (Num n, Ord n) => Prism' n (Positive n) Source #

For any numeric type n, Positive n is a subset of n.

Examples:

natPrism :: (Integral n, Bits n) => Prism' Natural (Positive n) Source #

For any integral type n, Positive n is a subset of Natural.

intPrism :: (Integral n, Bits n) => Prism' Integer (Positive n) Source #

For any integral type n, Positive n is a subset of Integer.

Re-exports

data Natural #

Type representing arbitrary-precision non-negative integers.

>>> 2^100 :: Natural
1267650600228229401496703205376

Operations whose result would be negative throw (Underflow :: ArithException),

>>> -1 :: Natural
*** Exception: arithmetic underflow

Since: base-4.8.0.0

Instances

Instances details
Enum Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Enum

Eq Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Natural

Methods

(==) :: Natural -> Natural -> Bool #

(/=) :: Natural -> Natural -> Bool #

Integral Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Real

Num Natural

Note that Natural's Num instance isn't a ring: no element but 0 has an additive inverse. It is a semiring though.

Since: base-4.8.0.0

Instance details

Defined in GHC.Num

Ord Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Natural

Read Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Read

Real Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Real

Show Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Show

Ix Natural

Since: base-4.8.0.0

Instance details

Defined in GHC.Ix

Bits Natural

Since: base-4.8.0

Instance details

Defined in Data.Bits

data Integer #

Arbitrary precision integers. In contrast with fixed-size integral types such as Int, the Integer type represents the entire infinite range of integers.

For more information about this type's representation, see the comments in its implementation.

Instances

Instances details
Enum Integer

Since: base-2.1

Instance details

Defined in GHC.Enum

Eq Integer 
Instance details

Defined in GHC.Integer.Type

Methods

(==) :: Integer -> Integer -> Bool #

(/=) :: Integer -> Integer -> Bool #

Integral Integer

Since: base-2.0.1

Instance details

Defined in GHC.Real

Num Integer

Since: base-2.1

Instance details

Defined in GHC.Num

Ord Integer 
Instance details

Defined in GHC.Integer.Type

Read Integer

Since: base-2.1

Instance details

Defined in GHC.Read

Real Integer

Since: base-2.0.1

Instance details

Defined in GHC.Real

Show Integer

Since: base-2.1

Instance details

Defined in GHC.Show

Ix Integer

Since: base-2.1

Instance details

Defined in GHC.Ix

Bits Integer

Since: base-2.1

Instance details

Defined in Data.Bits

type Prism' s a = Optic' A_Prism NoIx s a #

Type synonym for a type-preserving prism.

view :: forall k (is :: IxList) s a. Is k A_Getter => Optic' k is s a -> s -> a #

View the value pointed to by a getter.

If you want to view a type-modifying optic that is insufficiently polymorphic to be type-preserving, use getting.

review :: forall k (is :: IxList) t b. Is k A_Review => Optic' k is t b -> b -> t #

Retrieve the value targeted by a Review.

>>> review _Left "hi"
Left "hi"

preview :: forall k (is :: IxList) s a. Is k An_AffineFold => Optic' k is s a -> s -> Maybe a #

Retrieve the value targeted by an AffineFold.

>>> let _Right = prism Right $ either (Left . Left) Right
>>> preview _Right (Right 'x')
Just 'x'
>>> preview _Right (Left 'y')
Nothing