[Haskell-cafe] Differences in optimisiation with interactive and compiled mo

Daniel Fischer daniel.is.fischer at web.de
Sun Dec 11 08:59:55 EST 2005


Am Samstag, 10. Dezember 2005 22:42 schrieb Bulat Ziganshin:
> Hello Branimir,
>
> Saturday, December 10, 2005, 8:29:09 PM, you wrote:
> >>Can you check this version?
>
> and this:
>
> replace from to = repl
>   where repl s | Just remainder <- start_from from s  =  to ++ repl
> remainder repl (c:cs)  =  c : repl cs
>         repl [] = []
>
> start_from (x:xs) (y:ys) | x==y  =  start_from xs ys
> start_from [] str                =  Just str
> start_from _  _                  =  Nothing

This is the fastest, even without type signatures (those give a wee bit of 
extra speed).
Have you any idea why using a pattern guard is faster (not much, but 
consistently) than the equivalent case-expression?

Cheers,
Daniel


More information about the Haskell-Cafe mailing list