inits is too strict

Stefan O'Rear stefanor at cox.net
Wed Jun 13 09:54:03 EDT 2007


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


More information about the Haskell-prime mailing list