[Haskell-beginners] Data.Stream interleave implementation question

Frerich Raabe raabe at froglogic.com
Mon Aug 18 21:12:17 UTC 2014


On 2014-08-18 20:22, Curt McDowell wrote:
> Funny, I was trying the same Homework, implemented interleaveStreams using
> the same algorithm you did (taking one item from each stream per recursive
> call), and got the same result with the ruler function hanging. It was 
> also
> fixed by changing interleaveStreams to take from just one stream per call
> and switch back and forth between streams.

I hit the same problem when I did the exercise. In fact, it made me post
this question on StackOverflow, asking about how pattern matching might 
cause
the function to work differently:

http://stackoverflow.com/questions/25078598/why-would-using-head-tail-instead-of-pattern-matching-make-evaluation-terminate

I thought the answers were quite enlightening, if only to emphasize that
debugging this kind of problem is really difficult (to me). I only noticed
that not using pattern matching for the second argument of 'interleave' 
helps
by accident...

-- 
Frerich Raabe - raabe at froglogic.com
www.froglogic.com - Multi-Platform GUI Testing


More information about the Beginners mailing list