Suggestion for bang patterns documentation
Christian Maeder
Christian.Maeder at dfki.de
Fri Feb 27 07:46:59 EST 2009
Simon Peyton-Jones wrote:
> | <cite>
> | The let-binding can be recursive. However, it is much more common for
> | the let-binding to be non-recursive, in which case the following law
> | holds: (let !p = rhs in body) is equivalent to (case rhs of !p -> body)
> | </cite>
> |
> | Shouldn't the bang be removed in the final case pattern?
>
> No. If p was a simple variable, then
> case rhs of x -> body
> is non-strict in Haskell, but should be strict here.
Thanks for pointing this out. But the case with a simple variable (and
no distinction) is special anyway (sort of a monomorphic let binding).
> | P.S. It should be mentioned that ~ and ! only make sense for single
> | variant data types (like tuples)
>
> That isn't true. Both are useful for multi-variant types
Right, a non-empty list should behave like a pair as long as I don't
want to know the variant beforehand and thereby forcing evaluation anyway.
Cheers Christian
More information about the Glasgow-haskell-users
mailing list