[Haskell-cafe] What's different about quantified constraints since GHC 9.2?

Li-yao Xia lysxia at gmail.com
Tue Sep 20 21:07:11 UTC 2022


Dear Café,

There's a trick [1] involving quantified constraints (and usually type 
families) where a function has a quantified constraint (forall a. CF a) 
and which is explicitly instantiated with a well-placed type annotation 
(_ :: CF x => ...). Since GHC 9.2, this trick works without that type 
annotation. How did GHC get smarter at instantiating this quantified 
constraint? Below is a minimized example which compiles on GHC 9.2.1 but 
not 9.0.1 (haven't tested 9.0.2), unless you uncomment the last line.

Cheers,
Li-yao

[1]: an Iceland_jack trick 
https://gitlab.haskell.org/ghc/ghc/-/issues/14860#note_151394


{-# LANGUAGE TypeFamilies, FlexibleInstances, FlexibleContexts, 
QuantifiedConstraints, ScopedTypeVariables #-}
module A where

type family F a
class C a
class C (F a) => CF a

f :: C (F a) => a
f = undefined

g :: (forall a. CF a) => a
g = f
   -- :: forall a. CF a => a  -- needed until GHC 9.0.1 but not GHC 
9.2.1 (and later)



More information about the Haskell-Cafe mailing list