efficiency

Mike Gunter m@ryangunter.com
15 Jan 2002 10:08:43 -0800


> By the way, I don't understand why Haskell98 provides both strictness flags
> and newtype declarations.... it seems to me that
> newtype M [a1 a2 ....] = MC (...)
> should be exactly the same as
> data N [b1 b2 ....] = NC !(...)

The Haskell report (in the "Datatype Renamings" section, 4.2.3, -- the
one on newtype) explains the difference.  Translating some of the
examples there to your names, with

> newtype M = M Int
> m (M i)	= 42
> data    N = N !Int
> n (N i)	= 42

we get

  Main> m undefined
  42

but

  Main> n undefined
  *** Exception: Prelude.undefined

        mike