[GHC] #4157: A bug of dropWhileR in Data.Sequence
GHC
cvs-ghc at haskell.org
Sun Jul 4 08:12:39 EDT 2010
#4157: A bug of dropWhileR in Data.Sequence
----------------------------------+-----------------------------------------
Reporter: kazu-yamamoto | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: libraries (other) | Version: 6.12.3
Keywords: | Difficulty:
Os: Unknown/Multiple | Testcase:
Architecture: Unknown/Multiple | Failure: None/Unknown
----------------------------------+-----------------------------------------
Description changed by igloo:
Old description:
> The document of dropWhileR says: dropWhileR p xs is equivalent to
> reverse (dropWhileL p (reverse xs)).
>
> However,
>
> reverse $ dropWhileL (==4) $ reverse $ fromList [1,2,3,4]
> ==> fromList [1,2,3]
>
> dropWhileR (==4) $ fromList [1,2,3,4]
> ==> fromList [1,2]
>
> I guess the cause of bug is in breakl.
>
> Original:
> breakl p xs = foldr (\ i _ -> S.splitAt i xs) (xs, empty) (findIndicesL p
> xs)
>
> Fixed:
> breakl p xs = foldr (\ i _ -> S.splitAt (i+1) xs) (xs, empty)
> (findIndicesL p xs)
New description:
The document of dropWhileR says: dropWhileR p xs is equivalent to reverse
(dropWhileL p (reverse xs)).
However,
{{{
reverse $ dropWhileL (==4) $ reverse $ fromList [1,2,3,4]
==> fromList [1,2,3]
dropWhileR (==4) $ fromList [1,2,3,4]
==> fromList [1,2]
}}}
I guess the cause of bug is in breakl.
Original:
{{{
breakl p xs = foldr (\ i _ -> S.splitAt i xs) (xs, empty) (findIndicesL p
xs)
}}}
Fixed:
{{{
breakl p xs = foldr (\ i _ -> S.splitAt (i+1) xs) (xs, empty)
(findIndicesL p xs)
}}}
--
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4157#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list