I created a newtype
for Maybe Int
:
Prelude> newtype MaybeTuple = MaybeTuple { getMaybe :: Maybe Int}
Prelude> let m = MaybeTuple (Just 5)
Prelude> getMaybe m
Just 5
But how can I create a generic newtype
of Maybe a
?
Add the a
as a type parameter:
newtype MaybeTuple a = MaybeTuple { getMaybe :: Maybe a }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With