Data constructors and pattern matching

Simon Marlow simonmar@microsoft.com
Wed, 20 Feb 2002 13:29:38 -0000


> It seems to me that it might be very useful for a module to export the
> pattern matching operators for a datatype without exporting the
> constructors.  Suppose we have
>=20
> data A =3D X {a::Int, b::Float}
>=20
> And we want to maintain the invariant that b is a floating-point
> representation of a.  So normally we would have to use a completely
> abstract datatype, and provide constructors and destructors.  But in
> this case, it would actually make sense to provide the=20
> pattern-matching
> operator X, but not the data constructor X.  So I think it=20
> would be good
> to separate these in the module export syntax.

What's wrong with

	module M (A, a, b) where { ... }

?

Simon