
8 Aug
2015
8 Aug
'15
8:43 p.m.
One could discuss if "newtype" is really needed when we have "data" plus strictness annotations (personally I'm a bit unsure what the common use case for "case" is where they differ and what one might consider more natural).
Prelude> newtype A = A Int deriving Show Prelude> data B = B !Int deriving Show Prelude> let x = case x of A n -> A 1 in x A 1 Prelude> let y = case y of B n -> B 1 in y *** Exception: <<loop>>
P.S.: If you think this part of Haskell is a bit hard to read and confusing, I seriously propose a week or two in C++'s wonderful meta-programming world with templates... ;-)
Can't agree more