I quite like the argument that take is a total function and as such all its return values are from teh specificed range. I can also see the logic in
take n [] = [] where n > 0
taking n from nothing, or the empty set, returns nothing!
The same should apply to head and tail. head or tail  of [] should be [].

What does the list think?
Cheers, Paul
At 16:43 12/09/2007, you wrote:
Hi

On 12 Sep 2007, at 11:44, ChrisK wrote:

Conor McBride wrote:
I'd like operations to complain
about bogus input, rather than producing bogus output.

Then you want a runtime assertion checking error helpful Data.List 
replacement.

Could you use Control.Exception.assert and make a wrapper for 
Data.List?

http://www.haskell.org/ghc/docs/latest/html/users_guide/sec- assertions.html

Hmmm. It might be quite annoying to make it a wrapper if it's just a 
question
of appealing to error rather than returning dummy values in failure 
cases.
Defining the domain of a function can be quite like defining the 
function
itself. Also, sometimes there can be problems arriving at a Bool. For 
example,
zipping colists is a productive coprogram, and it can raise errors in
off-diagonal cases, but you can't compute in advance whether you're 
on the
diagonal.

A more serious point is that in some cases we might want take to
underapproximate, or zip to truncate (or tail [] = [] ?). I don't 
think there's
always a clear "library" choice here. I tend to be pragmatic about 
it. I was
just pointing out that it does sometimes make sense to use less defined
functions when one has a more specific domain in mind. I'm usually 
happy to
write the fussy variants myself, if I'm that agitated.

Funny old world

Conor

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