I want to create an Arbitrary
instance for the following newtype, in order to use it for QuickCheck:
newtype Wrapmaybe a = Wrapmaybe {getMaybe :: Maybe a} deriving (Eq, Show)
I know that the Arbitrary
instance for Maybe
can be written as follows:
instance Arbitrary a => Arbitrary (Maybe a) where
arbitrary = frequency [(1, return Nothing), (1, liftM Just arbitrary)]
How do I write the Arbitrary
instance for something like the following without getting a type error or kind error:
instance Arbitrary a => Arbitrary (Wrapmaybe Maybe a) where
etc...
Wrapmaybe
- perhaps you are looking fornewtype Wrap f a = Wrap (f a)
– user2407038