smart-math-0.1: Mathematical smart constructors
Safe HaskellNone
LanguageHaskell2010

Numeric.Data.Positive.Internal

Description

Provides the Positive type for enforcing a positive invariant.

Since: 0.1

Synopsis

Type

newtype Positive a Source #

Newtype wrapper that attaches a Positive invariant to some a. Positive is an ASemigroup and MGroup i.e. supports addition, multiplication, and division.

Since: 0.1

Constructors

UnsafePositive a 

Bundled Patterns

pattern MkPositive :: a -> Positive a

Unidirectional pattern synonym for Positive. This allows us to pattern match on a positive term without exposing the unsafe internal details.

Since: 0.1

Instances

Instances details
HasField "unPositive" (Positive a) a Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

getField :: Positive a -> a #

(k ~ A_Getter, x ~ a, y ~ a) => LabelOptic "unPositive" k (Positive a) (Positive a) x y Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

labelOptic :: Optic k NoIx (Positive a) (Positive a) x y Source #

Lift a => Lift (Positive a :: Type) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

lift :: Quote m => Positive a -> m Exp #

liftTyped :: forall (m :: Type -> Type). Quote m => Positive a -> Code m (Positive a) #

Num a => ASemigroup (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(.+.) :: Positive a -> Positive a -> Positive a Source #

(Division a, Integral a) => MEuclidean (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

mdivMod :: Positive a -> Positive a -> (Positive a, Positive a) Source #

(Division a, Num a) => MGroup (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(.%.) :: Positive a -> Positive a -> Positive a Source #

Num a => MMonoid (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

one :: Positive a Source #

Num a => MSemigroup (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

(.*.) :: Positive a -> Positive a -> Positive a Source #

Normed (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

norm :: Positive a -> Positive a Source #

(Num a, Ord a, Show a) => FromInteger (Positive a) Source #

WARNING: Partial

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

(Fractional a, Ord a, Show a) => FromRational (Positive a) Source #

WARNING: Partial

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Generic (Positive a) Source # 
Instance details

Defined in Numeric.Data.Positive.Internal

Associated Types

type Rep (Positive a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.Positive.Internal

type Rep (Positive a) = D1 ('MetaData "Positive" "Numeric.Data.Positive.Internal" "smart-math-0.1-inplace" 'True) (C1 ('MetaCons "UnsafePositive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Methods

from :: Positive a -> Rep (Positive a) x #

to :: Rep (Positive a) x -> Positive a #

Show a => Show (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

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

show :: Positive a -> String #

showList :: [Positive a] -> ShowS #

Bounded a => UpperBounded (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

UpperBoundless (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

NFData a => NFData (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

rnf :: Positive a -> () #

Eq a => Eq (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

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

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

Ord a => Ord (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

Methods

compare :: Positive a -> Positive a -> Ordering #

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

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

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

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

max :: Positive a -> Positive a -> Positive a #

min :: Positive a -> Positive a -> Positive a #

Show a => Display (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

type Rep (Positive a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.Positive.Internal

type Rep (Positive a) = D1 ('MetaData "Positive" "Numeric.Data.Positive.Internal" "smart-math-0.1-inplace" 'True) (C1 ('MetaCons "UnsafePositive" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 a)))

Creation

unsafePositive :: (HasCallStack, Num a, Ord a, Show a) => a -> Positive a Source #

Throws an error when given a value <= 0.

WARNING: Partial

Examples

Expand
>>> unsafePositive 7
UnsafePositive 7

Since: 0.1

Misc

errMsg :: Show a => String -> a -> String Source #

Since: 0.1