Copyright | (c) Michal Konecny |
---|---|
License | BSD3 |
Maintainer | mikkonecny@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- type CanMinMax t1 t2 = (CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t2 t1, MinMaxType t1 t2 ~ MinMaxType t2 t1)
- class CanMinMaxAsymmetric t1 t2 where
- type MinMaxType t1 t2
- min :: t1 -> t2 -> MinMaxType t1 t2
- max :: t1 -> t2 -> MinMaxType t1 t2
- type CanMinMaxThis t1 t2 = (CanMinMax t1 t2, MinMaxType t1 t2 ~ t1)
- type CanMinMaxSameType t = CanMinMaxThis t t
- minimum :: CanMinMaxSameType t => [t] -> t
- maximum :: CanMinMaxSameType t => [t] -> t
- specCanMinMax :: _ => T t1 -> T t2 -> T t3 -> Spec
- specCanMinMaxNotMixed :: _ => T t -> Spec
- class CanAbs t where
- type CanAbsSameType t = (CanAbs t, AbsType t ~ t)
- specCanNegNum :: _ => T t -> Spec
- specCanAbs :: _ => T t -> Spec
Minimum and maximum
type CanMinMax t1 t2 = (CanMinMaxAsymmetric t1 t2, CanMinMaxAsymmetric t2 t1, MinMaxType t1 t2 ~ MinMaxType t2 t1) Source #
class CanMinMaxAsymmetric t1 t2 where Source #
A replacement for Prelude's min
and max
. If t1 = t2
and Ord t1
,
then one can use the default implementation to mirror Prelude's min
and max
.
Nothing
type MinMaxType t1 t2 Source #
type MinMaxType t1 t2 = t1
min :: t1 -> t2 -> MinMaxType t1 t2 Source #
default min :: (MinMaxType t1 t2 ~ t1, t1 ~ t2, Ord t1) => t1 -> t2 -> MinMaxType t1 t2 Source #
max :: t1 -> t2 -> MinMaxType t1 t2 Source #
default max :: (MinMaxType t1 t2 ~ t1, t1 ~ t2, Ord t1) => t1 -> t2 -> MinMaxType t1 t2 Source #
Instances
type CanMinMaxThis t1 t2 = (CanMinMax t1 t2, MinMaxType t1 t2 ~ t1) Source #
type CanMinMaxSameType t = CanMinMaxThis t t Source #
minimum :: CanMinMaxSameType t => [t] -> t Source #
maximum :: CanMinMaxSameType t => [t] -> t Source #
Tests
specCanMinMax :: _ => T t1 -> T t2 -> T t3 -> Spec Source #
HSpec properties that each implementation of CanMinMax should satisfy.
specCanMinMaxNotMixed :: _ => T t -> Spec Source #
HSpec properties that each implementation of CanMinMax should satisfy.
Absolute value
A replacement for Prelude's abs
. If Num t
,
then one can use the default implementation to mirror Prelude's abs
.
Nothing
Instances
CanAbs Double Source # | |
CanAbs Int Source # | |
CanAbs Integer Source # | |
CanAbs Rational Source # | |
(CanMulAsymmetric t t, CanAddSameType (MulType t t), CanSqrt (MulType t t)) => CanAbs (Complex t) Source # | |
(CanAbs a, CanBeErrors es) => CanAbs (CollectErrors es a) Source # | |
Defined in Numeric.MixedTypes.MinMaxAbs type AbsType (CollectErrors es a) Source # abs :: CollectErrors es a -> AbsType (CollectErrors es a) Source # |
type CanAbsSameType t = (CanAbs t, AbsType t ~ t) Source #
Tests
specCanNegNum :: _ => T t -> Spec Source #
HSpec properties that each numeric implementation of CanNeg should satisfy.
specCanAbs :: _ => T t -> Spec Source #
HSpec properties that each implementation of CanAbs should satisfy.