
19 Sep
2007
19 Sep
'07
6:42 a.m.
I'm experimenting with functional reactive programming for creating simple 2D/3D video games and interactive apps, trying to develop my own version of it from scratch, for learning Haskell. I got stuck with an endless loop when trying to split a stream into a pair of two streams (a kind of reactive if/then/else). Luckily I first read the Haskell School of Expression so I remembered that pattern matching is not lazy and this could be the cause, which it was (I had to replace (x:xs) by ~(x:xs)) I could also fix the problem by not using pattern matching at all, using head/tail calls instead. Now why isn't pattern matching lazy by default? This seems odd for a newbie since everything else is lazy by default. Thanks, Peter