I have discovered that I can do this 1 :: Product Int
and get Product {getProduct = 1}
as a result.
Product
is a newtype
defined in Data.Monoid
. Than I have tried defining my own newtype
like so :
newtype Stuff a = Stuff {getStuff :: a} deriving (Show)
But if I try to do 1 :: Stuff Int
I get an error :
<interactive>:20:1: error:
* No instance for (Num (Stuff Int)) arising from the literal `1'
* In the expression: 1 :: Stuff Int
In an equation for `it': it = 1 :: Stuff Int
Do I have to put Num
constraint on a
or something? Why doesn't this work?