[Haskell-cafe] Strange subtract operator behavior - and lazy
naturals
Luke Palmer
lrpalmer at gmail.com
Sat Oct 20 22:49:59 EDT 2007
On 10/19/07, Yitzchak Gale <gale at sefer.org> wrote:
> So why not make the laziness available
> also for cases where "1 - 2 == 0" does _not_ do
> the right thing?
>
> data LazyInteger = IntZero | IntSum Bool Integer LazyInteger
>
> or
>
> data LazyInteger = LazyInteger Bool Nat
I think
data LazyInteger = IntDiff Nat Nat
would admit implementation of most of the nice properties of this
implementation. Comparison operators could short circuit when one of
the two naturals is zero. The only value which would diverge when
compared to a constant would be infinity - infinity.
Luke
More information about the Haskell-Cafe
mailing list