
On 1/14/13 1:09 PM, Simon Peyton-Jones wrote:
Friends
I'd like to propose a way to "promote" newtypes over their enclosing type. Here's the writeup http://hackage.haskell.org/trac/ghc/wiki/NewtypeWrappers
Any comments? Below is the problem statement, taken from the above page.
I'd appreciate
* A sense of whether you care. Does this matter?
I care. So far I've gotten around some of the problems by defining rewrite rules which take (fmap NT), (fmap unNT), etc into unsafeCoerce. I haven't run into the eta problems that I'm aware of, but the non-constant-time maps are something that shows up quite a lot. I'd prefer the second approach since it's cleaner to programmers: No new syntax; no namespace pollution. The one problem I could see is that there's no way to restrict export of the NTC instance, which may be necessary for correctness when the constructors aren't exported due to invariants...
* Improvements to the design I propose
I'd suggest the name newtypeCoerce (to match unsafeCoerce) rather than newtypeCast. The "casting" terminology isn't terribly common in Haskell (I don't think). -- Live well, ~wren