Copyright | Copyright (c) 2016 the Hakaru team |
---|---|
License | BSD3 |
Maintainer | wren@community.haskell.org |
Stability | experimental |
Portability | GHC-only |
Safe Haskell | None |
Language | Haskell2010 |
A collection of type classes for encoding Hakaru's numeric hierarchy.
- data HEq :: Hakaru -> * where
- class HEq_ a where
- sing_HEq :: HEq a -> Sing a
- hEq_Sing :: Sing a -> Maybe (HEq a)
- data HOrd :: Hakaru -> * where
- hEq_HOrd :: HOrd a -> HEq a
- class HEq_ a => HOrd_ a where
- sing_HOrd :: HOrd a -> Sing a
- hOrd_Sing :: Sing a -> Maybe (HOrd a)
- data HIntegrable :: Hakaru -> * where
- sing_HIntegrable :: HIntegrable a -> Sing a
- hIntegrable_Sing :: Sing a -> Maybe (HIntegrable a)
- data HSemiring :: Hakaru -> * where
- class HSemiring_ a where
- sing_HSemiring :: HSemiring a -> Sing a
- hSemiring_Sing :: Sing a -> Maybe (HSemiring a)
- data HRing :: Hakaru -> * where
- hSemiring_HRing :: HRing a -> HSemiring a
- hSemiring_NonNegativeHRing :: HRing a -> HSemiring (NonNegative a)
- class (HSemiring_ (NonNegative a), HSemiring_ a) => HRing_ a where
- type NonNegative (a :: Hakaru) :: Hakaru
- sing_HRing :: HRing a -> Sing a
- hRing_Sing :: Sing a -> Maybe (HRing a)
- sing_NonNegative :: HRing a -> Sing (NonNegative a)
- data HFractional :: Hakaru -> * where
- hSemiring_HFractional :: HFractional a -> HSemiring a
- class HSemiring_ a => HFractional_ a where
- sing_HFractional :: HFractional a -> Sing a
- hFractional_Sing :: Sing a -> Maybe (HFractional a)
- data HRadical :: Hakaru -> * where
- hSemiring_HRadical :: HRadical a -> HSemiring a
- class HSemiring_ a => HRadical_ a where
- sing_HRadical :: HRadical a -> Sing a
- hRadical_Sing :: Sing a -> Maybe (HRadical a)
- data HDiscrete :: Hakaru -> * where
- class HSemiring_ a => HDiscrete_ a where
- sing_HDiscrete :: HDiscrete a -> Sing a
- hDiscrete_Sing :: Sing a -> Maybe (HDiscrete a)
- data HContinuous :: Hakaru -> * where
- hFractional_HContinuous :: HContinuous a -> HFractional a
- hSemiring_HIntegralContinuous :: HContinuous a -> HSemiring (HIntegral a)
- class (HSemiring_ (HIntegral a), HFractional_ a) => HContinuous_ a where
- sing_HContinuous :: HContinuous a -> Sing a
- hContinuous_Sing :: Sing a -> Maybe (HContinuous a)
- sing_HIntegral :: HContinuous a -> Sing (HIntegral a)
Equality
data HEq :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types with decidable equality.
Haskell type class for automatic HEq
inference.
Ordering
data HOrd :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types with decidable total ordering.
HIntegrable
data HIntegrable :: Hakaru -> * where Source #
Concrete dictionaries for types where Infinity can have
JmEq1 Hakaru HIntegrable Source # | |
Eq1 Hakaru HIntegrable Source # | |
Eq (HIntegrable a) Source # | |
Show (HIntegrable a) Source # | |
sing_HIntegrable :: HIntegrable a -> Sing a Source #
hIntegrable_Sing :: Sing a -> Maybe (HIntegrable a) Source #
Semirings
data HSemiring :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types which are semirings. N.B., even though these particular semirings are commutative, we don't necessarily assume that.
class HSemiring_ a where Source #
Haskell type class for automatic HSemiring
inference.
sing_HSemiring :: HSemiring a -> Sing a Source #
Rings
data HRing :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types which are rings. N.B., even though these particular rings are commutative, we don't necessarily assume that.
hSemiring_NonNegativeHRing :: HRing a -> HSemiring (NonNegative a) Source #
class (HSemiring_ (NonNegative a), HSemiring_ a) => HRing_ a where Source #
Haskell type class for automatic HRing
inference.
Every HRing
has an associated type for the semiring of its
non-negative elements. This type family captures two notions.
First, if we take the semiring and close it under negation/subtraction
then we will generate this ring. Second, when we take the absolute
value of something in the ring we will get back something in the
non-negative semiring. For HInt
and HReal
these two notions
coincide; however for Complex and Vector types, the notions
diverge.
TODO: Can we somehow specify that the HSemiring (NonNegative
a)
semantics coincides with the HSemiring a
semantics? Or
should we just assume that?
type NonNegative (a :: Hakaru) :: Hakaru Source #
sing_HRing :: HRing a -> Sing a Source #
sing_NonNegative :: HRing a -> Sing (NonNegative a) Source #
Fractional types
data HFractional :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types which are division-semirings; i.e., division-rings without negation. This is called a "semifield" in ring theory, but should not be confused with the "semifields" of geometry.
JmEq1 Hakaru HFractional Source # | |
Eq1 Hakaru HFractional Source # | |
Eq (HFractional a) Source # | |
Show (HFractional a) Source # | |
hSemiring_HFractional :: HFractional a -> HSemiring a Source #
Every HFractional
is a HSemiring
.
class HSemiring_ a => HFractional_ a where Source #
Haskell type class for automatic HFractional
inference.
hFractional :: HFractional a Source #
sing_HFractional :: HFractional a -> Sing a Source #
hFractional_Sing :: Sing a -> Maybe (HFractional a) Source #
Radical types
data HRadical :: Hakaru -> * where Source #
Concrete dictionaries for semirings which are closed under all
HNat
-roots. This means it's closed under all positive rational
powers as well. (If the type happens to be HFractional
, then
it's closed under all rational powers.)
N.B., HReal
is not HRadical
because we do not have real-valued
roots for negative reals.
N.B., we assume not only that the type is surd-complete, but
also that it's still complete under the semiring operations.
Thus we have values like sqrt 2 + sqrt 3
which cannot be
expressed as a single root. Thus, in order to solve for zeros/roots,
we'll need solutions to more general polynomials than just the
x^n - a
polynomials. However, the Galois groups of these are
all solvable, so this shouldn't be too bad.
class HSemiring_ a => HRadical_ a where Source #
Haskell type class for automatic HRadical
inference.
sing_HRadical :: HRadical a -> Sing a Source #
Discrete types
data HDiscrete :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types which are "discrete".
class HSemiring_ a => HDiscrete_ a where Source #
Haskell type class for automatic HDiscrete
inference.
sing_HDiscrete :: HDiscrete a -> Sing a Source #
Continuous types
data HContinuous :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types which are "continuous".
This is an ad-hoc class for (a) lifting 'HNat'\/'HInt' into
'HProb'\/'HReal', and (b) handling the polymorphism of monotonic
functions like etf
.
JmEq1 Hakaru HContinuous Source # | |
Eq1 Hakaru HContinuous Source # | |
Eq (HContinuous a) Source # | |
Show (HContinuous a) Source # | |
hFractional_HContinuous :: HContinuous a -> HFractional a Source #
Every HContinuous
is a HFractional
.
hSemiring_HIntegralContinuous :: HContinuous a -> HSemiring (HIntegral a) Source #
The integral type of every HContinuous
is a HSemiring
.
class (HSemiring_ (HIntegral a), HFractional_ a) => HContinuous_ a where Source #
Haskell type class for automatic HContinuous
inference.
Every HContinuous
has an associated type for the semiring of
its integral elements.
TODO: Can we somehow specify that the HSemiring (HIntegral a)
semantics coincides with the HSemiring a
semantics? Or should
we just assume that?
hContinuous :: HContinuous a Source #
sing_HContinuous :: HContinuous a -> Sing a Source #
hContinuous_Sing :: Sing a -> Maybe (HContinuous a) Source #
sing_HIntegral :: HContinuous a -> Sing (HIntegral a) Source #