<div dir="ltr"><div>Like any good mystery, let's start with the body:<br><br>repro.hs:22:5:<br>    Couldn't match type `y0' with `y'<br>      because type variable `y' would escape its scope<br>    This (rigid, skolem) type variable is bound by<br>      a type expected by the context: Foo x y -> Bool<br>    The following variables have types that mention y0<br>      b :: Foo x0 y0 -> Bool (bound at repro.hs:18:9)<br>    Expected type: Foo x y -> Bool<br>      Actual type: Foo x0 y0 -> Bool<br>    In the first argument of `h', namely `b'<br>    In a stmt of a 'do' block: h b<br>    In the expression:<br>      do { xs <- return ["test"] :: IO [String];<br>           let a = ...<br>               b = ...;<br>           h b }<br>Failed, modules loaded: none.<br><br><br>So it's the "(rigid, skolem)" error you sometimes happen across. The code that's causing it, though, is pretty unsuspicious:<br><br><br><br>{-# LANGUAGE RankNTypes #-}<br>-- remove this pragma and it typechecks (1):<br>{-# LANGUAGE GADTs #-}<br><br>data Foo x y = Foo x y<br><br>main :: IO ()<br>main = do<br>    xs <- return ["test"] :: IO [String]<br><br>    let<br>        -- typechecks (2):<br>        -- a = Just "test" :: Maybe String<br>        -- typechecks (3):<br>        -- a = f ["test"]<br>        a = f xs :: Maybe String<br><br>        b = g (a :: Maybe String) :: forall x y. Foo x y -> Bool<br><br>    -- typechecks if it's inlined (4):<br>    -- h (g (a :: Maybe String) :: forall x y. Foo x y -> Bool)<br>    h b<br><br>f :: [a] -> Maybe a<br>f _ = Nothing<br><br>-- doesnt affect typechecking:<br>-- g :: Maybe String -> (Foo x y -> Bool)<br>g :: Maybe String -> (forall x y. Foo x y -> Bool)<br>g (Just _) _ = False<br>g Nothing _ = True<br><br>-- typechecks (5):<br>-- h :: (Foo x y -> Bool) -> IO ()<br>h :: (forall x y. Foo x y -> Bool) -> IO ()<br>h = undefined<br><br><br>This has been reproduced in ghc 7.6.3, 7.8.3, 7.8.4, and 7.10.1 RC1<br><br></div>Any idea what's going on?<br><br>Thanks!<br>Tom<br></div>