allbery.b at gmail.com
Tue Jan 15 00:43:26 CET 2013
On Mon, Jan 14, 2013 at 5:29 PM, Johan Tibell <johan.tibell at gmail.com>wrote:
> Let me rephrase: how will Simon's proposed "data constructors are in
> scope" mechanism work? For example, will
> let xs :: Map = ...
> in map MyNewtype xs
> behave differently if the constructors of Map are in scope or not?
If you allow deriving this without the constructors in scope, the user can
use it to violate the invariant (by the new type causing Map to think it is
sorted differently than it is, because there is a different Ord constraint).
Requiring the constructors to be in scope doesn't actually prevent this,
but does give the user some chance to do something about it. Meanwhile
something that deliberately hides its constructors to preserve an invariant
can't suddenly have that invariant violated by an errant use of this
brandon s allbery kf8nh sine nomine associates
allbery.b at gmail.com ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Glasgow-haskell-users