Instance selection regression from 7.4 to 7.6
The following code (useless due to minification) works in GHC 7.4.1:
{-# LANGUAGE FlexibleInstances, UndecidableInstances, OverlappingInstances #-}
class CollectArgs a where
randomEvaluate :: a -> ()
instance CollectArgs b => CollectArgs (a -> b) where
randomEvaluate f = randomEvaluate (f undefined)
where () = randomEvaluate (f undefined)
instance Show a => CollectArgs a where
randomEvaluate x = ()
In 7.6.2-rc1, I get this error message
test.hs:8:20:
Could not deduce (Show b) arising from a use of `randomEvaluate'
from the context (CollectArgs b)
bound by the instance declaration at test.hs:6:10-46
Possible fix:
add (Show b) to the context of the instance declaration
In the expression: randomEvaluate (f undefined)
In a pattern binding: () = randomEvaluate (f undefined)
In an equation for `randomEvaluate':
randomEvaluate f
= randomEvaluate (f undefined)
where
() = randomEvaluate (f undefined)
The error message goes away if I remove the () = randomEvaluate (f undefined)
binding, i.e. the first recursive use of randomEvaluate
works fine.
(This came up at http://stackoverflow.com/questions/14294802/evaluating-function-at-random-arguments-using-quickcheck/14295179#14295179)
Trac metadata
Trac field | Value |
---|---|
Version | 7.6.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |