[ ghc-Bugs-441613 ] take (-1) [] fails
noreply@sourceforge.net
noreply@sourceforge.net
Tue, 31 Jul 2001 03:56:43 -0700
Bugs item #441613, was opened at 2001-07-16 00:04
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=108032&aid=441613&group_id=8032
Category: Prelude
Group: 5.00
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: take (-1) [] fails
Initial Comment:
As described in the Haskell report, Prelude.take
applied to a negative argument and an empty list should
return an empty list. Hugs and HBC implements this
correctly, but GHC's implementation instead produces
Exception: Prelude.take: negative index
I have two large programs, that work fine when compiled
with HBC, and fail because of this when compiled when
GHC. I have examined all direct calls to take in one of
them and I am 93.7% certain that they cannot be the
cause of the problem, so I suspect the offending call
to take comes from another prelude/library function...
----------------------------------------------------------------------
>Comment By: Simon Marlow (simonmar)
Date: 2001-07-31 03:56
Message:
Logged In: YES
user_id=48280
My apologies - I infered from your bug report that you were
suggesting the bug was elsewhere in the prelude. It's true
that we haven't updated take/drop/splitAt with the recent
changes in the Haskell 98 definition (I've now fixed that).
----------------------------------------------------------------------
Comment By: Simon Marlow (simonmar)
Date: 2001-07-31 03:56
Message:
Logged In: YES
user_id=48280
My apologies - I infered from your bug report that you were
suggesting the bug was elsewhere in the prelude. It's true
that we haven't updated take/drop/splitAt with the recent
changes in the Haskell 98 definition (I've now fixed that).
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2001-07-30 09:13
Message:
Logged In: NO
Not enought information? The code that fails is in the
subject line!
You can easily verify it in ghci:
% ghci
___ ___ _
/ _ \ /\ /\/ __(_)
/ /_\// /_/ / / | | GHC Interactive, version
5.00.2, For Haskell 98.
/ /_\/ __ / /___| | http://www.haskell.org/ghc/
\____/\/ /_/\____/|_| Type :? for help.
Loading package std ... linking ... done.
Prelude> take (-1) ""
*** Exception: Prelude.take: negative index
I found code that seems consisent with this behavior in the
CVS repository
in fptools/libraries/core/GHC/List.lhs, in a section marked
/* hack away */
...
I also noted that in the revised Haskell 98 report, take
should always return
an empty list if the index is negative, i.e. even if the
argument list is
non-empty...
(I also discovered that the problem in my code was, I
suspected, not caused
by a direct call to take, but by a call to replicate with a
negative
argument...)
----------------------------------------------------------------------
Comment By: Simon Marlow (simonmar)
Date: 2001-07-30 03:13
Message:
Logged In: YES
user_id=48280
We don't have enough information to be able to analyse this
problem further. If the submitter is out there, could you
perhaps provide us with the code that fails? (and BTW,
could you login or otherwise include your email address in
the bug report next time so we can get in touch. Thanks.)
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=108032&aid=441613&group_id=8032