
Hello, inits [] = [[]] inits (x:xs) = [[]] ++ map (x:) (inits xs) as specified in Data.List has a "semantic bug", namely it's too strict: inits (1:_|_) = []:_|_ as opposed to the expected inits (1:_|_) = []:[1]:_|_ A correct version would be inits xs = []:case xs of [] -> [] (x:xs) -> map (x:) (inits xs) The Haskell report specifies how inits has to behave, so this is a problem in the report, not in a concrete implementation. Where can I report a bug report for the report? ;) Regards, apfelmus

apfelmus:
Hello,
inits [] = [[]] inits (x:xs) = [[]] ++ map (x:) (inits xs)
as specified in Data.List has a "semantic bug", namely it's too strict:
inits (1:_|_) = []:_|_
as opposed to the expected
inits (1:_|_) = []:[1]:_|_
A correct version would be
inits xs = []:case xs of [] -> [] (x:xs) -> map (x:) (inits xs)
The Haskell report specifies how inits has to behave, so this is a problem in the report, not in a concrete implementation. Where can I report a bug report for the report? ;)
Regards, apfelmus
Well, right here. There are other strictness issues either differing from the spec, or not clearly defined (foldl', for example). A useful tool for checking these is the StrictCheck/ChasingBottoms library, QuickCheck for partial values, by the way. -- Don

apfelmus:
Where can I report a bug report for the report? ;)
Stefan O'Rear wrote:
http://haskell.org/haskellwiki/Language_and_library_specification says:
The report still has minor bugs. There are tracked at the Haskell 98 bugs page. Report any new bugs to Malcolm Wallace.
Donald Bruce Stewart wrote:
Well, right here. There are other strictness issues either differing from the spec, or not clearly defined (foldl', for example).
Ah. Actually, I thought that there's something like a bug-tracker for the standardized libraries. I wouldn't change inits in the existing H98 standard, it's not really worth the hassle. But I'd change it to the lazy version for Haskell'.
A useful tool for checking these is the StrictCheck/ChasingBottoms library, QuickCheck for partial values, by the way.
Oh, really useful :) Regards, apfelmus

On Wed, Jun 13, 2007 at 11:48:18AM +0200, apfelmus wrote:
Hello,
inits [] = [[]] inits (x:xs) = [[]] ++ map (x:) (inits xs)
as specified in Data.List has a "semantic bug", namely it's too strict:
inits (1:_|_) = []:_|_
as opposed to the expected
inits (1:_|_) = []:[1]:_|_
A correct version would be
inits xs = []:case xs of [] -> [] (x:xs) -> map (x:) (inits xs)
The Haskell report specifies how inits has to behave, so this is a problem in the report, not in a concrete implementation. Where can I report a bug report for the report? ;)
http://haskell.org/haskellwiki/Language_and_library_specification says: The report still has minor bugs. There are tracked at the Haskell 98 bugs page. Report any new bugs to Malcolm Wallace. Stefan
participants (3)
-
apfelmus
-
dons@cse.unsw.edu.au
-
Stefan O'Rear