Hello,
I have a question on 'solitary constructors'; such a constructor is the only
one in its data type. It appears to me that pattern matching using these
constructors can be more lazy. To give an example from the Haskell 1.3
report, with
data D1 = D1 Int
d1 (D1 i) = 42
currently "d1 undefined" is equivalent to "undefined". The reason for this
is that "data" constructor patterns are refutable. But in the case of a
solitary constructor, it would make sense to make the pattern irrefutable.
This has already been done in the case of "newtype" constructors, which are
in fact a special kind of solitary constructor.
To change the behaviour of pattern matching for solitary constructors,
basically the current translation rules for "newtype" pattern matching have
to be generalized to solitary constructors. (These are rules (k) and (l) in
Figure 4, in section 3.17.3, p. 30 of the Haskell 1.3 Report.) As far as I
can see, this change of semantics doesn't break any existing code; it just
executes it a little more lazily.
I think this change would make it possible to replace e.g.
newtype N a b c = N (a, [b->c])
by
data N a b c = N !(a, [b->c])
thereby making the "newtype" keyword superfluous.
Any comments?
<><
Marnix
--
Marnix Klooster
[EMAIL PROTECTED]