Re: [Haskell-cafe] Re: [m..n] question

2008-09-23 Thread Brandon S. Allbery KF8NH

On 2008 Sep 22, at 5:46, Jon Fairbairn wrote:

"Richard A. O'Keefe" <[EMAIL PROTECTED]> writes:

It is being claimed that the reason for this is that "exceptions
are problematic" in Hasell, so the Haskell designers went out of
their way to make this function total whether it made sense or not.


I'm pretty sure that's not true.  I'd like to be able to say
"I know, I was there", but although I was there it was so
long ago that my memory isn't clear.  But it's clearly the


I would say it's more a matter of Haskell programmers thinking partial  
functions are evil as a general (mathematical) principle.  And the  
claimant above is thinking of needing to catch exceptions in IO, and  
probably comes from the school of programming that says that invalid  
values should raise exceptions.  Which sounds like a good idea until  
you see how often people do try {mumble()} catch {} or similar.  (Go  
look at some Java programs; Java goes even farther with that idea and  
requires programmers to declare the exceptions they can throw, so many  
programmers shortcircuit the exceptions away to avoid having to deal  
with it.)


--
brandon s. allbery [solaris,freebsd,perl,pugs,haskell] [EMAIL PROTECTED]
system administrator [openafs,heimdal,too many hats] [EMAIL PROTECTED]
electrical and computer engineering, carnegie mellon universityKF8NH


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


[Haskell-cafe] Re: [m..n] question

2008-09-22 Thread Jon Fairbairn
"Richard A. O'Keefe" <[EMAIL PROTECTED]> writes:

> Erlang's equivalent of [m..n] is lists:seq(M, N),
> which is currently defined to raise an exception when N < M.
> In particular, lists:seq(1, N) returns a list of length N
> when N > 0, but not when N = 0.
> I'm currently arguing that lists:seq(1, 0) should be [],
> not an exception.  Oddly enough, I'm being beaten over the
> head with Haskell, of all things.
>
> In Haskell,
> "The sequence enumFromTo e1 e3 is the list [e1,e1+1,e1+2,...e3].
>  The list is empty if e1 > e3."
>
> It is being claimed that the reason for this is that "exceptions
> are problematic" in Hasell, so the Haskell designers went out of
> their way to make this function total whether it made sense or not.

I'm pretty sure that's not true.  I'd like to be able to say
"I know, I was there", but although I was there it was so
long ago that my memory isn't clear.  But it's clearly the
case that [5 .. 6] is [5, 6] (length 2) and [5 .. 5] has to
be [5] (length 1), so it's not unreasonable to expect that
[5, 4] be [] (length 0) -- having the induction extend down
to there makes most sense.  I'm fairly certain it was
arguments about induction and what constituted sensible
behaviour rather than our admitted dislike for exceptions
that carried the argument.



-- 
Jón Fairbairn [EMAIL PROTECTED]


___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe