[Haskell-cafe] Re: Is "take" behaving correctly?
Jules Bean
jules at jellybean.co.uk
Thu Sep 13 04:43:38 EDT 2007
Neil Mitchell wrote:
> Hi
>
>> 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 have a zipWithEq function I often use, which crashes if the zip'd
> lists aren't equal. I also have tailSafe which does the tailSafe [] =
> [] behaviour. I created a hackage package "safe" for the tailSafe
> function and others, http://www-users.cs.york.ac.uk/~ndm/safe/ . If
> anyone wants to extend that with deliberately unsafe functions, such
> as zipWithUnsafe, zipUnsafe, takeUnsafe etc, I'd be happy to accept a
> patch. If not, I'll probably do it myself at some point in the
> (potentially distant) future.
Of course we have tailSafe in the standard library (if I correctly
understand what you mean) as "drop 1" and headSafe as "take 1".
I've rather got used to the exact details of head/tail, take/drop and
zip but I agree it's a bit arbitrary: counterintuitive until you learn
which is which and which is what.
Although I appluad the semantics of the safe package, I'm not delighted
with the idea of replacing our concise elegant standard library names
with uglyAndRatherLongCamelCaseNamesThatCouldBePerlOrEvenJava though.
Conciseness of expression is a virtue.
Jules
More information about the Haskell-Cafe
mailing list