[Haskell-cafe] Data & newtype differences. Today: strictness
roma at ro-che.info
Sun Jan 22 12:55:30 CET 2012
* Yves Parès <yves.pares at gmail.com> [2012-01-22 11:32:30+0100]
> These make me think that pattern matching against a newtype is always lazy
> (irrefutable). Am I right?
> Is there some litterature expliciting in a less empiric way than I did the
> differences like this between data and newtype? I've never come against
> such documentation through all my learning of Haskell, yet I think it's an
> important point.
See the Haskell report, section 3.17.2 "Informal Semantics of Pattern
In particular, this paragraph:
The irrefutable patterns are as follows: a variable, a wildcard, N
apat where N is a constructor defined by newtype and apat is
irrefutable (see Section 4.2.3), var at apat where apat is irrefutable,
or of the form ~apat (whether or not apat is irrefutable). All other
patterns are refutable.
Roman I. Cheplyaka :: http://ro-che.info/
More information about the Haskell-Cafe