Newtype wrappers in hsSyn

Simon Peyton-Jones simonpj at microsoft.com
Wed Jan 27 19:26:54 EST 2010


| > type PostTcType = Maybe Type
| >
| > Now you're representing the data that isn't there by a Nothing, rather
| > than a _|_. You could even newtype it and have fromPostTcType be
| > equivalent to fromJust with a helpful error about the ordering. It
| > will be slower than what's currently there, but also more accurate
| > statement of intent.
| 
| Yes, I don't know why it is implemented this way.  Probably to avoid an
| indirection and the memory overhead.  Could be worth measuring.

It's just that I didn't want to unwrap a Just that I knew was a Just!  An error thunk seemed just right. Using a newtype would do fine.

S



More information about the Cvs-ghc mailing list