Tue, 23 Oct 2001 08:00:34 -0700, Jeffrey R Lewis <[EMAIL PROTECTED]> pisze:
> The best solution is to find a good way to eliminate the DMR. Separating syntaxes of function definition and pattern binding would have the right effect IMHO, but it's a radical change which breaks compatibility and customs. As we are at it, perhaps there should be a way to write strict pattern bindings in let. I recently wrote this: ... some previous cases omitted ... escape (x:xs) = '\\':digit d2:digit d1:digit d0:escape xs where n = ord x (d21, d0) = n `quotRem` 10 (d2, d1) = d21 `quotRem` 10 digit d = chr (ord '0'+d) Laziness is completely unnecessary here, but GHC is not able to optimize it out (even though it has the right to do so; previous cases did evaluate x, and there is no division by zero nor out of range argument of chr). I'm not against lazy 'let' in general. I often write a large bunch of equations in 'where', letting the compiler solve dependencies. Making all tuple unpacking strict would be silly. There is no perfect solution... Adding '$!' or 'seq' here would make it ugly. I would like to seq not just d2,d1,d0 but digits converted to Char, so I would have to introduce three extra variables. In fact I would like to perform the computation which allocates the room for four list cells along with their Char objects in one go, and then computes and spreads all digits without further allocation. Only laziness for the final 'escape xs' is practical in this case. So it's like I want the first three (:) to be strict in both arguments and the last (:) to be strict in the first argument. Can't be written nicely in Haskell. What is the most readable way to eliminate all laziness here except final 'escape xs' in the current Haskell? What would have to be changed in the language to improve it? -- __("< Marcin Kowalczyk * [EMAIL PROTECTED] http://qrczak.ids.net.pl/ \__/ ^^ SYGNATURA ZASTĘPCZA QRCZAK _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell