[Haskell-cafe] data vs newtype (was: newbie problems)

MR K P SCHUPKE k.schupke at imperial.ac.uk
Mon Jul 5 14:08:48 EDT 2004


One difference is that Constuctors for 'data' can be curries,
whereas 'newtype' cannot:

        data X a b c = X a b c
        newtype X a b c = X (a,b,c)

But you have to balance this against newtypes being neater. Also data
can represend and abstract type:

	data X

whereas newtype cannot, also data can represent unitary types:

	data Y = Y

whereas newtype is limited to wrapping up void:

	newtype Z = Z ()

Keean.


More information about the Haskell-Cafe mailing list