GHC internal error while typechecking of instance definition
Hello. \\ This code won't typecheck because of GHC internal error.
{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds #-}
class C a where
type T (n :: a)
-- v--DIFF--v
instance C a => C b => C (a, b) where
type T '(n, m) = (T n, T m)
with error message:
Bug.hs:7:10: error:
• GHC internal error: ‘T’ is not in scope during type checking, but it passed the renamer
tcl_env of environment: [a1LS :-> Type variable ‘a’ = a :: *,
a1LT :-> Type variable ‘b’ = b :: *]
• In the type instance declaration for ‘T’
In the instance declaration for ‘C b => C (a, b)’
|
7 | type T (n, m) = (T n, T m)
| ^
Failed, no modules loaded.
but this works fine:
{-# LANGUAGE PolyKinds, TypeFamilies, DataKinds #-}
class C a where
type T (n :: a)
-- v--DIFF--v
instance (C a, C b) => C (a, b) where
type T '(n, m) = (T n, T m)
Not sure is a bug, but either way it would be better to make more understandable error message
Trac metadata
Trac field | Value |
---|---|
Version | 8.6.3 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | low |
Resolution | Unresolved |
Component | Compiler (Type checker) |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |