I am using the Data.List.Vector in my program, and now I would like to use quickCheck for it. However, there is no instance for that. Since there already is an arbitrary for [Double], I thought I could do something like
instance Arbitrary V.Vector Double where
arbitrary = V.fromList (arbitrary :: [Double])
alas, GHC does not like this at all:
`Arbitrary' is applied to too many type arguments
In the instance declaration for `Arbitrary V.Vector Double'
I guess I could also just make a bunch of properties that take in a [Double] and uses V.fromList, but that seems tedious.
Your problem is that you need to parenthesize it, like
instance Arbitrary (V.Vector Double), etc. But there’s a better way to do it:Note that you need the
fmapbecausearbitraryis a value of typeGen a, and so in order to go fromGen [a]toGen (V.Vector a)you need to liftV.fromListintoGen, which you can do since it’s a functor.