Changes between Version 20 and Version 21 of NewtypeWrappers


Ignore:
Timestamp:
Jan 24, 2014 8:14:15 PM (15 months ago)
Author:
slyfox
Comment:

typo: 'it it' -> 'it'

Legend:

Unmodified
Added
Removed
Modified
  • NewtypeWrappers

    v20 v21  
    3737Alas, not easily, and certainly not without overhead.   
    3838 
    39  * 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?  This is hard; apart from anything else, how would GHC know that `map` was special?  And it it gets worse. 
     39 * 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?  This is hard; apart from anything else, how would GHC know that `map` was special?  And it gets worse. 
    4040 
    4141 * For `x2` we'd have to eta-expand: `(\y -> MkAge (x2 y)) :: Char -> Age`.  But this isn't good either, because eta exapansion isn't semantically valid (if `x2` was bottom, `seq` could distinguish the two).  See #7542 for a real life example.