[Haskell-cafe] Are newtypes optimised and how much?

Simon Peyton-Jones simonpj at microsoft.com
Thu Oct 21 03:34:17 EDT 2010


| >> Yes, you can freely use Foo/unFoo. There's no runtime penalty. (In the
| >> jargon of GHC's intermediate language, Foo and unFoo translate to
| >> *type-safe casts*, which generate no executable code.
| >
| > When does the conversion to type-safe casts occur relative to other
| > optimizations (namely, rewrite rules)?
| 
| That is, I know that rewrite rules operate on the source language not on
| Core, but to what extent does that mean that type-safe casts inhibit the
| firing of rules?

Rewrite rules work on Core, not source, so they "see" the type-safe casts.  I don't know how to say "to what extent" they inhibit rules.  If you show an example I will try to help.

S


More information about the Haskell-Cafe mailing list