Skip to content
GitLab
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 5,242
    • Issues 5,242
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 567
    • Merge requests 567
  • 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 CompilerGlasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #17327
Closed
Open
Issue created Oct 09, 2019 by mniip@mniipReporter

Kind-checking associated types

Summary

When kind checking associated type declarations in an instance declaration, the instance context seems to be ignored.

Steps to reproduce

Minimal complete example:

{-# LANGUAGE DataKinds, PolyKinds, TypeFamilies, FlexibleContexts, FlexibleInstances, MultiParamTypeClasses, TypeApplications #-}
class C (k :: *) (a :: *) where
  type F k a :: k

data D k (x :: k)

instance C k (D k x) where
  type F k (D k x) = x -- good

instance (k ~ l) => C l (D k x) where
  type F l (D k x) = x -- bad
{-
b.hs:11:22: error:
    • Expected kind ‘l’, but ‘x’ has kind ‘k’
    • In the type ‘x’
      In the type instance declaration for ‘F’
      In the instance declaration for ‘C l (D k x)’
   |
11 |   type F l (D k x) = x -- bad
   |                      ^
-}

Expected behavior

The second instance should kind-check (it has better instance resolution properties than the first which is why we want it).

Environment

Tested on GHC 8.6.5 and GHC HEAD

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking