
24 Jan
2012
24 Jan
'12
10:25 a.m.
Yves Parès
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