[Haskell-cafe] Data & newtype differences. Today: strictness
Ketil Malde
ketil at malde.org
Tue Jan 24 11:25:56 CET 2012
Yves Parès <yves.pares at gmail.com> writes:
> I had for long thought that data and newtype were equivalent, but then I
> spotted some differences when it comes to strictness.
>
> data Test = Test Int
> newtype TestN = TestN Int
Interesting. I'd thought that
data Test = Test !Int
and
newtype Test = Test Int
would be equivalent, but here you (well, I had to add the ! myself) show
a situation where they're not.
I guess
pm (Test _) = 12
is the same as
pm = \x -> case x of Test _ -> 12
which perhaps makes it clearer why it breaks on undefined...
-k
--
If I haven't seen further, it is by standing in the footprints of giants
More information about the Haskell-Cafe
mailing list