[Haskell-cafe] a really juvenile question .. hehehehe ;^)

Don Stewart dons at galois.com
Mon Oct 6 03:12:20 EDT 2008


dagit:
>    data and newtype vary in one more subtle way, and that's how/when they
>    evaluate to bottom.  Most of the time they behave identically, but in the
>    right cases they act sightly differently.  newtype is usually regarded as
>    more efficient than data.  This is because the compiler can choose to
>    optimize away the newtype so that it only exists at type check time.  I
>    think this is also possible with data in some, but not all, uses.

The compiler *must* optimise away the use. They're sort of 'virtual'
data, guaranteed to have no runtime cost.

-- Don


More information about the Haskell-Cafe mailing list