Coverage Condition woes
Simon Peyton-Jones
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)
| where
| (nsa, rsa) = asRange a
| (nsb, rsb) = asRange b
|
| produces:
| Illegal instance declaration for `AsRange (rsa, rsb) (nsa, nsb)'
| (the Coverage Condition fails for one of the functional
| dependencies)
| 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:
http://www.haskell.org/ghc/dist/current/docs/users_guide/type-extensions
.html#instance-decls
(in 7.4.4.1).
You can find the background here
http://research.microsoft.com/%7Esimonpj/papers/fd%2Dchr/
However, if you add -fallow-undecidable-instances it'll be allowed (see
section 7.4.4.2).
Simon
More information about the Glasgow-haskell-users
mailing list