Stability | experimental |
---|---|
Maintainer | byorgey@cis.upenn.edu |
A simple implementation of intervals of natural numbers, for use in
tracking the possible sizes of structures of a species. For
example, the species x + x^2 + x^3
will correspond to the
interval [1,3].
- data NatO
- omega :: NatO
- natO :: (Integer -> a) -> a -> NatO -> a
- data Interval
- iLow :: Interval -> NatO
- iHigh :: Interval -> NatO
- decrI :: Interval -> Interval
- union :: Interval -> Interval -> Interval
- intersect :: Interval -> Interval -> Interval
- elem :: Integer -> Interval -> Bool
- toList :: Interval -> [Integer]
- natsI :: Interval
- fromI :: NatO -> Interval
- emptyI :: Interval
- omegaI :: Interval
The NatO
type
NatO
is an explicit representation of the co-inductive Nat type
which admits an infinite value, omega. Our intuition for the
semantics of NatO
comes from thinking of it as an efficient
representation of lazy unary natural numbers, except that we can
actually test for omega in finite time.
Eq NatO | |
Ord NatO | |
Show NatO | |
C NatO | In fact, |
C NatO |
|
The Interval
type
Interval operations
union :: Interval -> Interval -> IntervalSource
The union of two intervals is the smallest interval containing both.
intersect :: Interval -> Interval -> IntervalSource
The intersection of two intervals is the largest interval contained in both.