[Haskell-cafe] problem with IO, strictness, and "let"
Stefan O'Rear
stefanor at cox.net
Fri Jul 13 20:36:18 EDT 2007
On Fri, Jul 13, 2007 at 09:19:58PM -0300, Felipe Almeida Lessa wrote:
> On 7/13/07, Stefan O'Rear <stefanor at cox.net> wrote:
>> instance Eval Int where
>> ...
>> seq (-1) b = b
>> seq 0 b = b
>> seq 1 b = b
>> ...
>
> I don't think you need all these cases. In fact, you can write
>
> instance Eval Int where
> seq 0 b = b
> seq _ b = b
[snip long explanation of why this is correct]
I thought of that, but decided that it would just obscure things, so I
wrote out an infinite sequence of cases instead. This way it reinforces
the symmetry of the instances and doesn't depend on an (often lacking)
understanding of the pattern strictness rules.
Both are equally valid.
Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070713/f81d23db/attachment.bin
More information about the Haskell-Cafe
mailing list