Simon Peyton-Jones | 1 Nov 2010 10:26
Picon
Favicon
Gravatar

RE: Type error in GHC-7 but not in GHC-6.12.3

OK now I see.  

You are using impredicative polymorphism.  As I mentioned in my last message I've simplified the treatment
of impredicativity to follow (more or less) QML: http://research.microsoft.com/en-us/um/people/crusso/qml/



In the call to useWhich

	useWhich devs withDevice p f

you can see that 
	withDevice ∷ Monad pr
           ⇒ Device
           → (∀ s. RegionalDeviceHandle (RegionT s pr) → RegionT s pr α)
           → pr α

	useWhich ∷ ∀ k desc e (m ∷ * → *) α
         . (GetDescriptor e desc)
         ⇒ [e]
         → (e → k → m α)
         → (desc → Bool)
         → k
         → m α

So it follows that you must instantiate 
	k = (∀ s. RegionalDeviceHandle (RegionT s pr) → RegionT s pr α)
Arguably GHC should complain at this point unless you use -XImpredicativePolymorphism, but it doesn't.
       
Now, the arguemnnt 'f' in the call, is apparently compatible with this type *except* that f's type is
instantiated.  What you want is a way to say "don't instantiate f here".  QML provides a way to do that, via a
(Continue reading)


Gmane