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,251
    • Issues 5,251
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 583
    • Merge requests 583
  • 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
  • #17772
Closed
Open
Issue created Jan 31, 2020 by Ryan Scott@RyanGlScottMaintainer

CUSK-less class typechecks on 8.4, but not on 8.6+

This code will typecheck with GHC 8.0.2 through 8.4.4:

{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeInType #-}
module Bug where

import Data.Kind
import Data.Proxy

class C f where
  type T (x :: f a) :: Type

  sT :: forall a (x :: f a).
        Proxy x -> T x

However, it mysteriously does not typecheck on GHC 8.6.5 or later:

$ /opt/ghc/8.8.2/bin/ghc Bug.hs
[1 of 1] Compiling Bug              ( Bug.hs, Bug.o )

Bug.hs:13:22: error:
    • Expected kind ‘f a’, but ‘x’ has kind ‘f a1’
    • In the first argument of ‘T’, namely ‘x’
      In the type signature: sT :: forall a (x :: f a). Proxy x -> T x
      In the class declaration for ‘C’
   |
13 |         Proxy x -> T x
   |                      ^

I cannot think of a good reason why this shouldn't typecheck, especially since there appears to be no polymorphic recursion happening in C, T, or sT.

Some observations:

  • Giving C a CUSK (i.e., class C (f :: k -> Type) where ...) makes it typecheck:

  • Splitting up C into two classes like so also makes it typecheck:

    class C1 f where
      type T (x :: f a) :: Type
    
    class C2 f where
      sT :: forall a (x :: f a).
            Proxy x -> T x
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking