Newtype wrappers

Stephen Paul Weber singpolyma at
Mon Jan 14 20:47:38 CET 2013

Somebody claiming to be Simon Peyton-Jones wrote:
>  *   For x1 we can write map MkAge x1 :: [Age]. But this does not follow 
>  the newtype cost model: there will be runtime overhead from executing the 
>  map at runtime, and sharing will be lost too. Could GHC optimise the map 
>  somehow?

My friend pointed out something interesting:

If GHC can know that MkAge is just id (in terms of code, not in terms of 
type), which seems possible, and if the only interesting case is a Functor, 
which seems possible, then a RULE fmap id = id would solve this.  No?

Stephen Paul Weber, @singpolyma
See <> for how I prefer to be contacted
edition right joseph
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <>

More information about the Glasgow-haskell-users mailing list