An interesting use case for this is that while data Void = Void Void
has infinitely many values (undefined, Void undefined, Void (Void undefined) etc), the newtype version newtype Void = Void Void has only one, bottom. This is a way to define the empty datatype without extensions. Erik On Tue, Jan 24, 2012 at 11:25, Ketil Malde <ke...@malde.org> wrote: > Yves Parès <yves.pa...@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 > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe