Skip to content

Type inference regression from GHC 8.10.7 to 9.0.2/9.2.3

The following is accepted (with a warning telling the solution to _) on GHC 8.10.7, but fails to type check on newer GHCs:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE PartialTypeSignatures #-}
{-# LANGUAGE RankNTypes #-}

module Main where

import GHC.TypeLits
import Data.Functor.Identity
import Data.Functor.Const
import Data.Functor


-- import fluff
type ASetter s t a b = (a -> Identity b) -> s -> Identity t
type Getting r s a = (a -> Const r a) -> s -> Const r s 
type Lens s t a b = forall f . Functor f => (a -> f b) -> (s -> f t)
type Traversal s t a b = forall f . Applicative f => (a -> f b) -> (s -> f t)

set :: ASetter s t a b -> b -> s -> t
set = undefined

view :: MonadReader s m => Getting a s a -> m a
view = undefined

class Monad m => MonadReader r (m :: * -> *) | m -> r where
instance MonadReader r ((->) r) where


-- test case
  
data Item (a :: *) (f :: Symbol -> * -> *)

l :: Lens (Item a f) (Item a' g) (f "1" ()) (g "1" ())
l = undefined

type ExoticTraversal' a y f = Traversal
          (Item a f)
          (Item a f)
          (f y ())
          (f y ())

test :: ExoticTraversal' a _ f
test f x = f (view l x) <&> \w -> set l w x


main :: IO ()
main = pure ()
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information