non-question, instance decl
Ketil Z. Malde
ketil@ii.uib.no
14 Jan 2003 10:46:53 +0100
Hi,
experimenting with QuickCheck, I write
> instance (Arbitrary e) => Arbitrary (Array Int e) where
> arbitrary = undefined
and I get:
| Illegal instance declaration for `Arbitrary (Array Int e)'
| (The instance type must be of form (T a b c)
| where T is not a synonym, and a,b,c are distinct type variables)
| In the instance declaration for `Arbitrary (Array Int e)'
|Failed, modules loaded: QuickCheck.
Okay, after experimenting a bit (more fun than reading documentation)
I see what's happening: I can't instantiate a halfway specialized
type, but 'Ix i => Arbitrary (Array i e)' is Okay.
Unfortunately, I really depend on i being Int in my (real) definition
of 'arbitrary'. I got around it by liberal doses of 'fromInteger' and
a 'Num' context -- ugly, but it seems to work.
I suppose there's a solid reason why my previous attempt is illegal?
-kzm
--
If I haven't seen further, it is by standing in the footprints of giants