[Haskell-cafe] Re: Is "take" behaving correctly?

Conor McBride ctm at cs.nott.ac.uk
Wed Sep 12 11:43:19 EDT 2007


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



More information about the Haskell-Cafe mailing list