Skip to content

Hidden rigid type variable in GHCi

Summary

I'm getting an error in GHCi which mentions a rigid type variable that I didn't define myself. I thought rigid type variables were always user-defined, is that not true? Does GHCi insert rigid type variables without my knowledge?

Steps to reproduce

ghci> :set -XRankNTypes
ghci> data Jet a
ghci> :{
ghci| run :: forall a. Jet a -> forall s. (s -> Bool) -> (s -> a -> IO s) -> s -> IO s
ghci| run x = undefined x
ghci| :}
ghci> :t map run

<interactive>:1:5: error:
    • Couldn't match type ‘b’
                     with ‘forall s. (s -> Bool) -> (s -> a -> IO s) -> s -> IO s’
      Expected: Jet a -> b
        Actual: Jet a
                -> forall s. (s -> Bool) -> (s -> a -> IO s) -> s -> IO s
      ‘b’ is a rigid type variable bound by
        the inferred type of it :: [Jet a] -> [b]
        at <interactive>:1:1
    • In the first argument of ‘map’, namely ‘run’
      In the expression: map run

Expected behavior

I expected an error like "Cannot instantiate unification variable ‘b’ with a type involving polytypes".

Environment

  • GHC version used: 9.0.1
Edited by Jaro Reinders
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information