Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-24 Thread wren ng thornton
On 6/21/12 1:15 PM, Brandon Allbery wrote: On Thu, Jun 21, 2012 at 5:11 AM, Rouan van Dalenwrote: Can anyone shed some light on why the succ and pred functions of the Enum typeclass throw exceptions if we go over the upper or lower boundary, and not return Maybe a? Enum and Bounded have a co

Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-22 Thread Alexander Solla
I hit reply instead of reply all. Sorry Richard. On Fri, Jun 22, 2012 at 4:35 PM, wrote: > > > An ordering does not typically induce a computable enumeration. For > > example, there are infinitely many rationals between any pair of > > rationals. > > I didn't say it was odd that Ords weren't E

Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-22 Thread ok
> An ordering does not typically induce a computable enumeration. For > example, there are infinitely many rationals between any pair of > rationals. I didn't say it was odd that Ords weren't Enums, I said that it's odd that Enums aren't Ords. It makes little or no sense to make treat rationals

Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-22 Thread Alexander Solla
On Thu, Jun 21, 2012 at 5:36 PM, Richard O'Keefe wrote: It always struck me as odd that Enum doesn't extend Ord. > There's a reason given for not having Bounded extend Ord, > which doesn't really apply to a class having fromEnum :: a -> Int. > Testing whether an enum bound is at a limit is thus a

Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-21 Thread Richard O'Keefe
On 21/06/2012, at 9:11 PM, Rouan van Dalen wrote: > I was hoping to have some functions like: > > safeSucc :: (Enum a) => a -> Maybe a > Types that are instances of Enum don't necessarily have bounds. It always struck me as odd that Enum doesn't extend Ord. There's a reason given for not havi

Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-21 Thread Brandon Allbery
On Thu, Jun 21, 2012 at 5:11 AM, Rouan van Dalen wrote: > Can anyone shed some light on why the succ and pred functions of the Enum > typeclass throw > exceptions if we go over the upper or lower boundary, and not return Maybe > a? > Enum and Bounded have a complicated and arguably incorrect[1] r

Re: [Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-21 Thread Francesco Mazzoli
At Thu, 21 Jun 2012 10:11:24 +0100 (BST), Rouan van Dalen wrote: > Hi everyone, > > Can anyone shed some light on why the succ and pred functions of the Enum > typeclass throw > exceptions if we go over the upper or lower boundary, and not return Maybe a? > > I was hoping to have some functions

[Haskell-cafe] Why does Enum succ and pred functions throw exception

2012-06-21 Thread Rouan van Dalen
Hi everyone, Can anyone shed some light on why the succ and pred functions of the Enum typeclass throw exceptions if we go over the upper or lower boundary, and not return Maybe a? I was hoping to have some functions like:   safeSucc :: (Enum a) => a -> Maybe a Because the succ and pred functi