Core Lint error
This piece of code fails when run with `ghci -ignore-dot-ghci -fdefer-type-errors -dcore-lint bug.hs`, maybe same as my previous #14584.
```hs
{-# Language DerivingStrategies #-}
{-# Language GeneralizedNewtypeDeriving #-}
{-# Language InstanceSigs #-}
{-# Language KindSignatures #-}
{-# Language PolyKinds #-}
{-# Language ScopedTypeVariables #-}
{-# Language TypeApplications #-}
{-# Language TypeFamilies #-}
{-# Language TypeInType #-}
{-# Language TypeOperators #-}
{-# Language UndecidableInstances #-}
import Data.Kind
import Data.Functor.Identity
import Data.Functor.Product
type a <-> b = a -> b -> Type
class Iso (iso :: a <-> b) where
iso :: a -> b
osi :: b -> a
data Iso_Bool :: Either () () <-> Bool
instance Iso Iso_Bool where
class Representable f where
type Rep f :: Type
index :: f a -> (Rep f -> a)
tabulate :: (Rep f -> a) -> f a
class Comonad w where
extract :: w a -> a
duplicate :: w a -> w (w a)
newtype Co f a = Co (f a) deriving newtype (Functor, Representable)
instance (Representable f, Monoid (Rep f)) => Comonad (Co f) where
extract = (`index` mempty)
newtype WRAP (iso::old <-> new) f a = WRAP (f a)
instance (Representable f, Rep f ~ old, Iso iso) => Representable (WRAP (iso :: old <-> new) f) where
type Rep (WRAP (iso :: old <-> new) f) = new
index :: WRAP iso f a -> (new -> a)
index (WRAP fa) = index fa . osi @old @new @iso
tabulate :: (new -> a) -> WRAP iso f a
tabulate gen = WRAP $
tabulate (gen . iso @old @new @iso)
newtype PAIR a = PAIR (Co (WRAP Iso_Bool (Product Identity Identity)) a)
deriving newtype
Comonad
```
I unfortunately don't have time to find a more minimal example. Core linter vomits a lot of errors on 8.2.1 & 8.3.20171208.
<details><summary>Trac metadata</summary>
| Trac field | Value |
| ---------------------- | ------------ |
| Version | 8.2.2 |
| Type | Bug |
| TypeOfFailure | OtherFailure |
| Priority | normal |
| Resolution | Unresolved |
| Component | Compiler |
| Test case | |
| Differential revisions | |
| BlockedBy | |
| Related | |
| Blocking | |
| CC | |
| Operating system | |
| Architecture | |
</details>
<!-- {"blocked_by":[],"summary":"Core Lint error","status":"New","operating_system":"","component":"Compiler","related":[],"milestone":"","resolution":"Unresolved","owner":{"tag":"Unowned"},"version":"8.2.2","keywords":["DeferredTypeErrors","TypeInType,"],"differentials":[],"test_case":"","architecture":"","cc":[""],"type":"Bug","description":"This piece of code fails when run with `ghci -ignore-dot-ghci -fdefer-type-errors -dcore-lint bug.hs`, maybe same as my previous #14584.\r\n\r\n{{{#!hs\r\n{-# Language DerivingStrategies #-}\r\n{-# Language GeneralizedNewtypeDeriving #-}\r\n{-# Language InstanceSigs #-}\r\n{-# Language KindSignatures #-}\r\n{-# Language PolyKinds #-}\r\n{-# Language ScopedTypeVariables #-}\r\n{-# Language TypeApplications #-}\r\n{-# Language TypeFamilies #-}\r\n{-# Language TypeInType #-}\r\n{-# Language TypeOperators #-}\r\n{-# Language UndecidableInstances #-}\r\n\r\nimport Data.Kind\r\nimport Data.Functor.Identity\r\nimport Data.Functor.Product\r\n\r\ntype a <-> b = a -> b -> Type\r\n\r\nclass Iso (iso :: a <-> b) where\r\n iso :: a -> b\r\n osi :: b -> a\r\n\r\ndata Iso_Bool :: Either () () <-> Bool\r\n\r\ninstance Iso Iso_Bool where\r\n\r\nclass Representable f where\r\n type Rep f :: Type\r\n\r\n index :: f a -> (Rep f -> a)\r\n tabulate :: (Rep f -> a) -> f a\r\n\r\nclass Comonad w where\r\n extract :: w a -> a\r\n duplicate :: w a -> w (w a)\r\n\r\nnewtype Co f a = Co (f a) deriving newtype (Functor, Representable)\r\n\r\ninstance (Representable f, Monoid (Rep f)) => Comonad (Co f) where\r\n extract = (`index` mempty)\r\n\r\nnewtype WRAP (iso::old <-> new) f a = WRAP (f a)\r\n\r\ninstance (Representable f, Rep f ~ old, Iso iso) => Representable (WRAP (iso :: old <-> new) f) where\r\n type Rep (WRAP (iso :: old <-> new) f) = new\r\n\r\n index :: WRAP iso f a -> (new -> a)\r\n index (WRAP fa) = index fa . osi @old @new @iso\r\n\r\n tabulate :: (new -> a) -> WRAP iso f a\r\n tabulate gen = WRAP $ \r\n tabulate (gen . iso @old @new @iso)\r\n\r\nnewtype PAIR a = PAIR (Co (WRAP Iso_Bool (Product Identity Identity)) a)\r\n deriving newtype\r\n Comonad \r\n}}}\r\n\r\nI unfortunately don't have time to find a more minimal example. Core linter vomits a lot of errors on 8.2.1 & 8.3.20171208. ","type_of_failure":"OtherFailure","blocking":[]} -->
issue