Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a `newtype Maybe a`

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?

like image 536
Kevin Meredith Avatar asked Jul 30 '14 03:07

Kevin Meredith


1 Answers

Add the a as a type parameter:

newtype MaybeTuple a = MaybeTuple { getMaybe :: Maybe a }
like image 84
Ørjan Johansen Avatar answered Nov 04 '22 13:11

Ørjan Johansen