Type-changing record update ignores type families
I would like this to compile:
type family F (a :: Bool)
type instance F True = Int
type instance F False = Int
type family G (a :: Bool)
type instance G True = Int
type instance G False = Bool
data Rec a = MkR { konst :: F a
, change :: G a }
ch :: Rec True -> Rec False
ch r = r { change = False }
The ch
function does a type-changing record update. Normally, a type-changing record update can be written only when all fields that mention the changing type variable are updated. And ch
does not update konst
, whose type mentions a
. But it's OK, actually: because F True
(old type) and F False
(new type) are actually both Int
, all is well. Yet GHC rejects.
Unlike some bugs I report, this one is from a Real Use Case. (I have a practical, fancy-typed library I'm building that wants to ensure that a particular record-update updates certain fields.)
While in town, should probably also fix #10856 (closed) and transitively #2595 (closed) (which, I think, is effectively a dup of #10856 (closed)).