Skip to content

Regression in Coercible solver with type constructor variables

Summary

GHC 9.6.0 alpha2 rejects the following use of coerce that was accepted in 9.4

Steps to reproduce

{-# LANGUAGE FlexibleInstances #-}
module G where

import Data.Functor.Const (Const ())
import Data.Coerce

f :: Coercible (f a) a => Const a () -> Const (f a) ()
f = coerce

Expected behavior

That compiles on GHC 9.4.

On 9.6 alpha2:

G.hs:8:5: error: [GHC-18872]
    • Couldn't match representation of type: Const a ()
                               with that of: Const (f a) ()
        arising from a use of ‘coerce’
        The data constructor ‘Data.Functor.Const.Const’
          of newtype ‘Const’ is not in scope
    • In the expression: coerce
      In an equation for ‘f’: f = coerce
    • Relevant bindings include
        f :: Const a () -> Const (f a) () (bound at G.hs:8:1)
  |
8 | f = coerce
  |     ^^^^^^
Edited by sheaf
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information