Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,936
    • Issues 4,936
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 456
    • Merge requests 456
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #10808
Closed
Open
Created Aug 29, 2015 by Iavor S. Diatchki@yavDeveloper

Odd interaction between record update and type families

Consider the following example

{-# LANGUAGE TypeFamilies #-}

type family F a
type family G a

data T1
type instance F T1 = Char
type instance G T1 = Int

data T2
type instance F T2 = Bool
type instance G T2 = Int

data R a = R { x :: F a, y :: G a }

r1 :: R T1
r1 = R { x = 'a', y = 2 }

r2 :: R T2
r2 = r1 { x = True }  -- error: Cannot match T1 with T2

r3 :: R T2
r3 = r1 { x = True, y = y r1 } -- OK

The error for r2 is odd because types R T1 and R T2 differ only in the type of x, so if we start with a value of type R T1, and update the field where the types differ, we should end up with a valid value of type R T2.

The fact that r2 is OK is demonstrated by r3 where we update the other field with its own value, and now the type checker is happy.

Trac metadata
Trac field Value
Version 7.10.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking