takeWhile does not participate in list fusion
takeWhile
doesn't do the list fusion thing. This alternative definition seems to fix that, at least to a great extent. It fused completely in a simple test, and incompletely but still usefully in a more complex one. I don't know how to write the appropriate translate/untranslate RULES for it yet.
{-# LANGUAGE ScopedTypeVariables #-}
takeWhileFB :: forall a . (a -> Bool) -> [a] -> [a]
takeWhileFB p xs = build tw'
where
tw' :: forall b . (a -> b -> b) -> b -> b
tw' kons knil = foldr go knil xs
where
go x rest | p x = x `kons` rest
| otherwise = knil
Trac metadata
Trac field | Value |
---|---|
Version | 7.8.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | libraries/base |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | ekmett, hvr |
Operating system | |
Architecture |