If newtype = data !, then why use does Haskell' need newtype

Dan Weston westondan at imageworks.com
Thu Oct 11 17:32:25 EDT 2007


I presume that the two statements below are equivalent [1]:

newtype A = MkA  Int
data    A = MkA !Int

So does Haskell' still need newtype? It seems like a needless keyword.

----------
[1] I ran ghc -c -fglasgow-exts -O -ddump-simpl and renamed identifiers 
to match, then did a diff, resulting in identical Tidy Core except for 
an explicit (inlined) reification function unused elsewhere:

Main.$WMkA :: GHC.Base.Int -> Main.A
[DataConWrapper]
[Arity 1
  NoCafRefs
  Str: DmdType Sm]
Main.$WMkA =
   __inline_me (\ (tpl_A1 :: GHC.Base.Int) ->
		 case tpl_A1 of tpl1_A1 { __DEFAULT -> Main.MkA tpl1_A1 })

which I take to mean simply:

Main.$WMkA = Main.MkA



More information about the Haskell-prime mailing list