Safe Haskell | None |
---|---|
Language | Haskell2010 |
A prelude for NumHask
- module Protolude
- (<>) :: Semigroup a => a -> a -> a
- class Semigroup a where
- fromString :: IsString a => String -> a
- fail :: Monad m => forall a. String -> m a
- data Complex a :: * -> * = !a :+ !a
- data Natural :: *
- module NumHask.Algebra.Additive
- module NumHask.Algebra.Basis
- module NumHask.Algebra.Distribution
- module NumHask.Algebra.Field
- module NumHask.Algebra.Integral
- module NumHask.Algebra.Magma
- module NumHask.Algebra.Metric
- module NumHask.Algebra.Module
- module NumHask.Algebra.Multiplicative
- module NumHask.Algebra.Rational
- module NumHask.Algebra.Ring
- module NumHask.Algebra.Singleton
Backend
NumHask imports Protolude as the prelude and replaces much of the Num
heirarchy in base.
Usage of Semigroup
and Monoid
has been avoided to retain basic compatability.
module Protolude
The class of semigroups (types with an associative binary operation).
Since: 4.9.0.0
(<>) :: a -> a -> a infixr 6 #
An associative operation.
(a<>
b)<>
c = a<>
(b<>
c)
If a
is also a Monoid
we further require
(<>
) =mappend
Reduce a non-empty list with <>
The default definition should be sufficient, but this can be overridden for efficiency.
stimes :: Integral b => b -> a -> a #
Repeat a value n
times.
Given that this works on a Semigroup
it is allowed to fail if
you request 0 or fewer repetitions, and the default definition
will do so.
By making this a member of the class, idempotent semigroups and monoids can
upgrade this to execute in O(1) by picking
stimes = stimesIdempotent
or stimes = stimesIdempotentMonoid
respectively.
Semigroup Ordering | Since: 4.9.0.0 |
Semigroup () | Since: 4.9.0.0 |
Semigroup Void | Since: 4.9.0.0 |
Semigroup Event | Since: 4.10.0.0 |
Semigroup Lifetime | Since: 4.10.0.0 |
Semigroup All | Since: 4.9.0.0 |
Semigroup Any | Since: 4.9.0.0 |
Semigroup IntSet | |
Semigroup Doc | |
Semigroup [a] | Since: 4.9.0.0 |
Semigroup a => Semigroup (Maybe a) | Since: 4.9.0.0 |
Semigroup a => Semigroup (IO a) | Since: 4.10.0.0 |
Ord a => Semigroup (Min a) | Since: 4.9.0.0 |
Ord a => Semigroup (Max a) | Since: 4.9.0.0 |
Semigroup (First a) | Since: 4.9.0.0 |
Semigroup (Last a) | Since: 4.9.0.0 |
Monoid m => Semigroup (WrappedMonoid m) | Since: 4.9.0.0 |
Semigroup a => Semigroup (Option a) | Since: 4.9.0.0 |
Semigroup (NonEmpty a) | Since: 4.9.0.0 |
Semigroup a => Semigroup (Identity a) | Since: 4.9.0.0 |
Semigroup a => Semigroup (Dual a) | Since: 4.9.0.0 |
Semigroup (Endo a) | Since: 4.9.0.0 |
Num a => Semigroup (Sum a) | Since: 4.9.0.0 |
Num a => Semigroup (Product a) | Since: 4.9.0.0 |
Semigroup (First a) | Since: 4.9.0.0 |
Semigroup (Last a) | Since: 4.9.0.0 |
Num a => Semigroup (Colour a) | |
Num a => Semigroup (AlphaColour a) |
|
Semigroup (IntMap a) | |
Semigroup (Seq a) | |
Ord a => Semigroup (Set a) | |
Semigroup (Doc a) | |
Semigroup b => Semigroup (a -> b) | Since: 4.9.0.0 |
Semigroup (Either a b) | Since: 4.9.0.0 |
(Semigroup a, Semigroup b) => Semigroup (a, b) | Since: 4.9.0.0 |
Semigroup (Proxy k s) | Since: 4.9.0.0 |
Ord k => Semigroup (Map k v) | |
(Semigroup a, Semigroup b, Semigroup c) => Semigroup (a, b, c) | Since: 4.9.0.0 |
Semigroup a => Semigroup (Const k a b) | Since: 4.9.0.0 |
Alternative f => Semigroup (Alt * f a) | Since: 4.9.0.0 |
Semigroup a => Semigroup (Tagged k s a) | |
(Semigroup a, Semigroup b, Semigroup c, Semigroup d) => Semigroup (a, b, c, d) | Since: 4.9.0.0 |
(Semigroup a, Semigroup b, Semigroup c, Semigroup d, Semigroup e) => Semigroup (a, b, c, d, e) | Since: 4.9.0.0 |
fromString :: IsString a => String -> a #
fail :: Monad m => forall a. String -> m a #
Fail with a message. This operation is not part of the
mathematical definition of a monad, but is invoked on pattern-match
failure in a do
expression.
As part of the MonadFail proposal (MFP), this function is moved
to its own class MonadFail
(see Control.Monad.Fail for more
details). The definition here will be removed in a future
release.
Complex numbers are an algebraic type.
For a complex number z
,
is a number with the magnitude of abs
zz
,
but oriented in the positive real direction, whereas
has the phase of signum
zz
, but unit magnitude.
The Foldable
and Traversable
instances traverse the real part first.
!a :+ !a infix 6 | forms a complex number from its real and imaginary rectangular components. |
Type representing arbitrary-precision non-negative integers.
Operations whose result would be negative
.throw
(Underflow
:: ArithException
)
Since: 4.8.0.0
NatS# GmpLimb# | in |
NatJ# !BigNat | in Invariant: |
Enum Natural | Since: 4.8.0.0 |
Eq Natural | |
Integral Natural | Since: 4.8.0.0 |
Num Natural | Since: 4.8.0.0 |
Ord Natural | |
Read Natural | Since: 4.8.0.0 |
Real Natural | Since: 4.8.0.0 |
Show Natural | Since: 4.8.0.0 |
Ix Natural | Since: 4.8.0.0 |
Lift Natural | |
Bits Natural | Since: 4.8.0.0 |
ToRatio Natural | |
Signed Natural | |
Integral Natural | |
ToInteger Natural | |
FromInteger Natural | |
Semiring Natural | |
InvolutiveRing Natural | |
Distribution Natural | |
MultiplicativeMagma Natural | |
MultiplicativeUnital Natural | |
MultiplicativeAssociative Natural | |
MultiplicativeCommutative Natural | |
Multiplicative Natural | |
AdditiveMagma Natural | |
AdditiveUnital Natural | |
AdditiveAssociative Natural | |
AdditiveCommutative Natural | |
Additive Natural | |
Normed Natural Natural | |
Metric Natural Natural | |
type (><) * * Natural Natural | |
Algebraic Heirarchy
Re-defines the numeric tower.
Instances for Int
, Integer
, Float
, Double
, Bool
, Complex
and Natural
are supplied.
module NumHask.Algebra.Additive
module NumHask.Algebra.Basis
module NumHask.Algebra.Distribution
module NumHask.Algebra.Field
module NumHask.Algebra.Integral
module NumHask.Algebra.Magma
module NumHask.Algebra.Metric
module NumHask.Algebra.Module
module NumHask.Algebra.Rational
module NumHask.Algebra.Ring
module NumHask.Algebra.Singleton