#4282: Data.List.intersperse not lazy enough
----------------------------------+-----------------------------------------
Reporter: daniel.is.fischer | Owner:
Type: proposal | Status: new
Priority: normal | Component: libraries/base
Version: 6.12.3 | Keywords: intersperse, laziness
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Other
----------------------------------+-----------------------------------------
Comment(by dons):
As Duncan says, during the stream fusion work we identified some of the
strictness properties of core functions were unusual. The List library
has,
{{{
intersperse :: a -> [a] -> [a]
intersperse _ [] = []
intersperse _ [x] = [x]
intersperse sep (x:xs) = x : sep : intersperse sep xs
}}}
But we wanted,
{{{
intersperse :: a -> [a] -> [a]
intersperse _ [] = []
intersperse sep (x0:xs0) = x0 : go xs0
where
go [] = []
go (x:xs) = sep : x : go xs
}}}
Related by
{{{
prop_intersperse = Test.intersperse `refines2` Spec.intersperse
prop_intercalate = Test.intercalate `refines2` Spec.intercalate
}}}
There is an extensive set of strictness properties for Data.List now that
we could use to improve their specification.
For the strictness property suite, look at,
http://code.haskell.org/~dons/code/stream-fusion/tests/Strictness/
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4282#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs