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

Numeric.Data.NonNegative.Internal

Description

Provides the NonNegative type for enforcing a nonnegative invariant.

Since: 0.1

Synopsis

Type

newtype NonNegative a Source #

Newtype wrapper that attaches a NonNegative invariant to some a. NonNegative is a Semifield i.e. supports addition, multiplication, and division.

Since: 0.1

Constructors

UnsafeNonNegative a 

Bundled Patterns

pattern MkNonNegative :: a -> NonNegative a

Unidirectional pattern synonym for NonNegative. This allows us to pattern match on a non-negative term without exposing the unsafe internal details.

Since: 0.1

Instances

Instances details
HasField "unNonNegative" (NonNegative a) a Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Methods

getField :: NonNegative a -> a #

(k ~ A_Getter, x ~ a, y ~ a) => LabelOptic "unNonNegative" k (NonNegative a) (NonNegative a) x y Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Methods

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

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

Num a => AMonoid (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Methods

zero :: NonNegative a Source #

Num a => ASemigroup (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Num a => MMonoid (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Methods

one :: NonNegative a Source #

Num a => MSemigroup (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Normed (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

(Division a, Num a) => Semifield (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Num a => Semiring (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

WARNING: Partial

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

WARNING: Partial

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

(Bounded a, Num a) => Bounded (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Generic (NonNegative a) Source # 
Instance details

Defined in Numeric.Data.NonNegative.Internal

Associated Types

type Rep (NonNegative a)

Since: smart-math-0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

Methods

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

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

Show a => Show (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Num a => LowerBounded (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

UpperBounded a => UpperBounded (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

UpperBoundless (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

NFData a => NFData (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Methods

rnf :: NonNegative a -> () #

Eq a => Eq (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Ord a => Ord (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

Show a => Display (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

type Rep (NonNegative a) Source #

Since: 0.1

Instance details

Defined in Numeric.Data.NonNegative.Internal

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

Creation

unsafeNonNegative :: (HasCallStack, Num a, Ord a, Show a) => a -> NonNegative a Source #

Throws an error when given a value < 0.

WARNING: Partial

Examples

Expand
>>> unsafeNonNegative 7
UnsafeNonNegative 7

Since: 0.1

Misc

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

Since: 0.1