Coverage Condition woes
simonpj at microsoft.com
Thu Aug 31 09:48:39 EDT 2006
| The following code (coming from Vertigo), which compiles OK with
| ghc-6.4.2, is rejected by ghc in HEAD (from this week-end) :
| data Range = Range String Float Float Float
| class AsRange nrs ns | nrs -> ns where
| asRange :: nrs -> (ns, [Range])
| instance (AsRange rsa nsa, AsRange rsb nsb)
| => AsRange (rsa, rsb) (nsa, nsb) where
| asRange (a, b) = ((nsa, nsb), rsa++rsb)
| (nsa, rsa) = asRange a
| (nsb, rsb) = asRange b
| Illegal instance declaration for `AsRange (rsa, rsb) (nsa, nsb)'
| (the Coverage Condition fails for one of the functional
| In the instance declaration for `AsRange (rsa, rsb) (nsa, nsb)'
| Is it normal ?
Yes, this is exactly as expected. (The fact that 6.4.2 allowed it was
really a bug.) The behaviour is documented here:
You can find the background here
However, if you add -fallow-undecidable-instances it'll be allowed (see
More information about the Cvs-ghc