| Copyright | Copyright (c) 2016 the Hakaru team |
|---|---|
| License | BSD3 |
| Maintainer | wren@community.haskell.org |
| Stability | experimental |
| Portability | GHC-only |
| Safe Haskell | None |
| Language | Haskell2010 |
Language.Hakaru.Types.HClasses
Contents
Description
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.
Minimal complete definition
Ordering
data HOrd :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types with decidable total ordering.
Constructors
| HOrd_Nat :: HOrd HNat | |
| HOrd_Int :: HOrd HInt | |
| HOrd_Prob :: HOrd HProb | |
| HOrd_Real :: HOrd HReal | |
| HOrd_Array :: !(HOrd a) -> HOrd (HArray a) | |
| HOrd_Bool :: HOrd HBool | |
| HOrd_Unit :: HOrd HUnit | |
| HOrd_Pair :: !(HOrd a) -> !(HOrd b) -> HOrd (HPair a b) | |
| HOrd_Either :: !(HOrd a) -> !(HOrd b) -> HOrd (HEither a b) |
class HEq_ a => HOrd_ a where Source #
Haskell type class for automatic HOrd inference.
Minimal complete definition
HIntegrable
data HIntegrable :: Hakaru -> * where Source #
Concrete dictionaries for types where Infinity can have
Constructors
| HIntegrable_Nat :: HIntegrable HNat | |
| HIntegrable_Prob :: HIntegrable HProb |
Instances
| 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.
Constructors
| HSemiring_Nat :: HSemiring HNat | |
| HSemiring_Int :: HSemiring HInt | |
| HSemiring_Prob :: HSemiring HProb | |
| HSemiring_Real :: HSemiring HReal |
class HSemiring_ a where Source #
Haskell type class for automatic HSemiring inference.
Minimal complete definition
Instances
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?
Minimal complete definition
Associated Types
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.
Constructors
| HFractional_Prob :: HFractional HProb | |
| HFractional_Real :: HFractional HReal |
Instances
| 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.
Minimal complete definition
Methods
hFractional :: HFractional a Source #
Instances
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.
Constructors
| HRadical_Prob :: HRadical HProb |
class HSemiring_ a => HRadical_ a where Source #
Haskell type class for automatic HRadical inference.
Minimal complete definition
sing_HRadical :: HRadical a -> Sing a Source #
Discrete types
data HDiscrete :: Hakaru -> * where Source #
Concrete dictionaries for Hakaru types which are "discrete".
Constructors
| HDiscrete_Nat :: HDiscrete HNat | |
| HDiscrete_Int :: HDiscrete HInt |
class HSemiring_ a => HDiscrete_ a where Source #
Haskell type class for automatic HDiscrete inference.
Minimal complete definition
Instances
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.
Constructors
| HContinuous_Prob :: HContinuous HProb | |
| HContinuous_Real :: HContinuous HReal |
Instances
| 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?
Minimal complete definition
Methods
hContinuous :: HContinuous a Source #
Instances
sing_HContinuous :: HContinuous a -> Sing a Source #
hContinuous_Sing :: Sing a -> Maybe (HContinuous a) Source #
sing_HIntegral :: HContinuous a -> Sing (HIntegral a) Source #