Impredicative types error
simonpj at microsoft.com
Wed Feb 1 13:54:24 CET 2012
Impredicative polymorphism has always been a soggy area of GHC -- the mixture of type inference and impredicativity is a genuinely difficult problem as you'll see from reading the papers. GHC 7 is less ambitious than GHC 6, and does a bit less.
Tim Sheard, Dimitrios Vytiniotis and I are working on a solid story. But meanwhile GHC's current implementation is a bit unpredictable, frankly.
My advice: use a newtype to wrap up the polymorphism:
newtype Denamer = MkD (forall n. Denamable n => n -> n)
getDeName :: Tc Denamer
| -----Original Message-----
| From: glasgow-haskell-users-bounces at haskell.org [mailto:glasgow-haskell-
| users-bounces at haskell.org] On Behalf Of John Meacham
| Sent: 31 January 2012 20:58
| To: glasgow-haskell-users at haskell.org
| Subject: Impredicative types error
| Hi, I am running into an issue where some code that compiled and
| worked under 6.12 is failing under 7.0, the offending code is
| class DeNameable a where
| deName :: Module -> a -> a
| getDeName :: Tc (DeNameable n => n -> n)
| getDeName = do
| mn <- asks (tcInfoModName . tcInfo)
| return (\n -> deName mn n)
| Tc is a plain typechecking monad and this returns a generic denaming
| function that can be used to turn haskell names back into human
| readable form before printing errors in jhc.
| I have the ImpredicativeTypes LANGUAGE feature turned on.
| the error I get under 7.0 is
| Couldn't match expected type `n -> n'
| with actual type `DeNameable n'
| In the second argument of `deName', namely `n'
| In the expression: deName mn n
| In the first argument of `return', namely `(\ n -> deName mn n)'
| Glasgow-haskell-users mailing list
| Glasgow-haskell-users at haskell.org
More information about the Glasgow-haskell-users