[Haskell-cafe] ghc-9 needs type declaration where ghc-8 didn't (with RankNTypes)

Johannes Waldmann johannes.waldmann at htwk-leipzig.de
Thu Oct 1 16:19:01 UTC 2020

Dear Cafe,

and thanks, Georgi, for answering my previous question

here's another difference I noticed
(based on real code, but reduced to a minimal test case)

GHCi, version https://www.haskell.org/ghc/  :? for help
Prelude> :set -XRankNTypes
Prelude> let f :: (forall a . a -> ()) -> () ; f = g ; g x = undefined

<interactive>:2:43: error:
    • Couldn't match type ‘p0’ with ‘forall a. a -> ()’
      Expected: (forall a. a -> ()) -> ()
        Actual: p0 -> ()
      Cannot instantiate unification variable ‘p0’
      with a type involving polytypes: forall a. a -> ()
    • In the expression: g
      In an equation for ‘f’: f = g

The declaration is accepted by ghc-8.
For ghc-9, I have to give a type signature for g (copy that of f),
or replace `f = g` with  `f x = g x`.

- J.W.

More information about the Haskell-Cafe mailing list