Safe Haskell | None |
---|---|
Language | Haskell2010 |
Numeric.Data.Positive.Internal
Description
Provides the Positive
type for enforcing a positive invariant.
Since: 0.1
Synopsis
- newtype Positive a where
- UnsafePositive a
- pattern MkPositive :: a -> Positive a
- unsafePositive :: (HasCallStack, Num a, Ord a, Show a) => a -> Positive a
- errMsg :: Show a => String -> a -> String
Type
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 Since: 0.1 |
Instances
Creation
unsafePositive :: (HasCallStack, Num a, Ord a, Show a) => a -> Positive a Source #
Throws an error when given a value <= 0.
WARNING: Partial
Examples
>>>
unsafePositive 7
UnsafePositive 7
Since: 0.1