Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
Synopsis
- class POrd a => PCountable (a :: S -> Type) where
- psuccessor :: forall (s :: S). Term s (a :--> a)
- psuccessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a))
- class PCountable a => PEnumerable (a :: S -> Type) where
- ppredecessor :: forall (s :: S). Term s (a :--> a)
- ppredecessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a))
Type classes
class POrd a => PCountable (a :: S -> Type) where Source #
A notion of 'next' value. More formally, instances of this type class are discrete linear orders with no maximal element.
Laws
x /= psuccessor x
y < x
=
psuccessor y <= x
x < psuccessor y
=
x <= y
If you define psuccessorN
, you must also ensure the following hold; the
default implementation ensures this.
psuccessorN 1
=
psuccessor
psuccessorN n . psuccessorN m
=
psuccessorN (n + m)
Law 1 ensures no value is its own successor. Laws 2 and 3 ensure that there
are no 'gaps': every value is 'reachable' from any lower value by a
finite number of applications of successor
.
@since WIP
psuccessor :: forall (s :: S). Term s (a :--> a) Source #
@since WIP
psuccessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a)) Source #
The default implementation of this function is inefficient: if at all possible, give instances an optimized version that doesn't require recursion.
@since WIP
Instances
PCountable PInteger Source # | @since WIP |
PCountable PPositive Source # | @since WIP |
class PCountable a => PEnumerable (a :: S -> Type) where Source #
Similar to PCountable
, but has the ability to get a 'previous' value as
well. More formally, instances of this type class are discrete linear orders
with no maximal or minimal element.
Laws
ppredecessor . psuccessor
=
psuccessor . ppredecessor
=
id
If you define ppredecessorN
, you must also ensure the following hold; the
default implementation ensures this.
ppredecessorN 1
=
ppredecessor
ppredecessorN n . ppredecessorN m
=
ppredecessorN (n + m)
From Law 1, we obtain the following theorem:
x /= predecessor x
@since WIP
ppredecessor :: forall (s :: S). Term s (a :--> a) Source #
@since WIP
ppredecessorN :: forall (s :: S). Term s (PPositive :--> (a :--> a)) Source #
The default implementation of this function is inefficient: if at all possible, give instances an optimized version that doesn't require recursion.
@since WIP