[Haskell-cafe] is there a way to prove the equivalence of these
two implementations of (Prelude) break function?
dav.vire+haskell at gmail.com
Tue Jun 8 02:33:51 EDT 2010
On Sun, Jun 6, 2010 at 5:10 AM, Thomas Hartman <tphyahoo at gmail.com> wrote:
> Here's two implementations of break, a snappy one from the prelude,
> prelbreak p xs = (takeWhile (not . p) xs,dropWhile (not . p) xs) --
> fast, more or less as implemented in prelude iiuc
I had a look at the prelude, and I was surprised to see there's 2 versions,
depending on a flag :
break p = span (not . p)
-- HBC version (stolen)
break _ xs@ = (xs, xs)
break p xs@(x:xs')
| p x = (,xs)
| otherwise = let (ys,zs) = break p xs' in (x:ys,zs)
I'm curious why is it so, and which version is compiled in the platform or
the ghc binaries.
( my guess is USE_REPORT_PRELUDE compiles functions as defined in the
haskell report, but the other version is faster and used by default. )
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe