[Haskell-cafe] instance Enum Double considered not entirely great?
jake.mcarthur at gmail.com
Tue Sep 20 17:38:21 CEST 2011
On Tue, Sep 20, 2011 at 10:59 AM, Chris Smith <cdsmith at gmail.com> wrote:
> The better way to look at this is that the notion of `succ` and `pred`
> is dependent on the type, much like `mappend` has no particular meaning
> until a Monoid instance is given for the type. It's fairly well
> established, though undocumented, that Num types ought to have succ =
> (+1) and pred = (subtract 1), so if your fixed point type doesn't do
> that, I'd suggest it is the problematic part of this.
I forgot to address this in my last email. I disagree that it is well
established for succ = (+1) and pred = subtract 1 for Num instances.
In fact, for types that are also instances of Bounded where the Num
instances have overflow this is required to be *not* true. Not
realizing this is a often a source of performance problems or even
bugs in Haskell programs.
More information about the Haskell-Cafe