On Tue, 9 Jan 2001, Robert F. Pointon wrote:

> I agree in general, however in this case there is only one clause so it
> does not need to evaluate to decide which clause to commit to. Ideally
> the compiler should detect this specific situation where there is one
> pattern that always matches.

OTOH evaluation of the argument early may improve performance. Usually
the purpose of writing a pattern in a function's parameter is to use
components of the value in its rhs, such that the value of the rhs is
meaningless without all the components. If the argument matched early,
the compiler can determine that the function is strict and generate more
efficient code for calling it.

In rare cases when the body makes sense without some components of
parameters, you can use lazy patterns or let or functions like head
instead of pattern matching or whatever.

-- 
Marcin 'Qrczak' Kowalczyk


_______________________________________________
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to