Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • GHC GHC
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
    • Locked files
  • Issues 5.5k
    • Issues 5.5k
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 639
    • Merge requests 639
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
    • Test cases
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Analytics
    • Analytics
    • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #4484

Regression: Combination of GADTs and Type families

The function "fails" compiles in 6.12.3 but not in 7.1 HEAD.

{-# LANGUAGE TypeFamilies, EmptyDataDecls, GADTs #-}

type family F f :: *

data Id c = Id
type instance F (Id c) = c

data C :: * -> * where
  C :: f -> C (W (F f))

data W :: * -> *

fails :: C a -> C a
fails (C _) = C Id

works :: C (W a) -> C (W a)
works (C _) = C Id

The error is:

    Could not deduce (F (Id c) ~ F f) from the context (a ~ W (F f))
    NB: `F' is a type function, and may not be injective
    Expected type: a
      Actual type: W (F (Id c))
    In the expression: C Id
    In an equation for `fails': fails (C _) = C Id

But in the function "works" the compiler apparently has no problem deducing (F (Id c) ~ F f).

Trac metadata
Trac field Value
Version 7.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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