Coverage Condition fails

Hello folks, Could somebody explain what a coverage condition is and what this error message means.. "Illegal instance declaration for 'GT (GT2 map1 map2) (k1,k2)' (the Coverage Condition fails for one of the functional dependencies) In the instance declaration for 'GT (GT2 map1 map2) (k1,k2)'" The offending code looks like this..
-- Generalsed Trie map class class Ord k => GT map k | map -> k , k -> map where
-- Map type for pairs newtype (GT2 map1 map2 a) = GT2 (map1 (map2 a))
-- Which is an instance of GT instance (GT map1 k1, GT map2 k2) => GT (GT2 map1 map2) (k1,k2) where
This is with ghc 6.6. The strange thing is this code used to compile fine with earlier versions (but I don't know if it actually worked because I never tested it). Thanks -- Adrian Hey

The coverage condition is described in the paper http://research.microsoft.com/~simonpj/papers/fd-chr Use -fallow-undecidable-instances to make it compile. Simoin | -----Original Message----- | From: glasgow-haskell-users-bounces@haskell.org [mailto:glasgow-haskell-users- | bounces@haskell.org] On Behalf Of Adrian Hey | Sent: 30 December 2006 23:26 | To: glasgow-haskell-users@haskell.org | Subject: Coverage Condition fails | | Hello folks, | | Could somebody explain what a coverage condition is and | what this error message means.. | | "Illegal instance declaration for 'GT (GT2 map1 map2) (k1,k2)' | (the Coverage Condition fails for one of the functional dependencies) | In the instance declaration for 'GT (GT2 map1 map2) (k1,k2)'" | | The offending code looks like this.. | | > -- Generalsed Trie map class | > class Ord k => GT map k | map -> k , k -> map where | | > -- Map type for pairs | > newtype (GT2 map1 map2 a) = GT2 (map1 (map2 a)) | | > -- Which is an instance of GT | > instance (GT map1 k1, GT map2 k2) => GT (GT2 map1 map2) (k1,k2) where | | This is with ghc 6.6. The strange thing is this code used to compile | fine with earlier versions (but I don't know if it actually worked | because I never tested it). | | Thanks | -- | Adrian Hey | | | | | _______________________________________________ | Glasgow-haskell-users mailing list | Glasgow-haskell-users@haskell.org | http://www.haskell.org/mailman/listinfo/glasgow-haskell-users

Simon Peyton-Jones wrote:
The coverage condition is described in the paper http://research.microsoft.com/~simonpj/papers/fd-chr
Use -fallow-undecidable-instances to make it compile.
Thanks, it seems to compile now. I've had a quick look at the paper you mentioned and I also see the latest ghc user guide has something to say about this too. But I'm still not really clear about what the problem is :-( (But I haven't really had time to study the paper properly yet either.)
| > -- Generalsed Trie map class | > class Ord k => GT map k | map -> k , k -> map where | | > -- Map type for pairs | > newtype (GT2 map1 map2 a) = GT2 (map1 (map2 a)) | | > -- Which is an instance of GT | > instance (GT map1 k1, GT map2 k2) => GT (GT2 map1 map2) (k1,k2) where
Intuitively, this looks quite unambigous to me and allowing undecidable anything worries me a bit. It makes me think my code is inherently flakey somehow (not sure how right now though :-). Regards -- Adrian Hey
participants (2)
-
Adrian Hey
-
Simon Peyton-Jones