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,255
    • Issues 5,255
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 563
    • Merge requests 563
  • 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
  • #18891
Closed
Open
Issue created Oct 26, 2020 by Richard Eisenberg@raeDeveloper

Kind inference for newtypes in GADT syntax is deeply broken

Here are some tales of destruction, all with -XUnliftedNewtypes and -XNoCUSKs:

newtype N :: forall k. TYPE k where
  MkN :: N -> N

gives

Scratch.hs:34:3: error:
    • Expected a type, but ‘N’ has kind ‘*’
    • In the definition of data constructor ‘MkN’
      In the newtype declaration for ‘N’

type N :: forall k. TYPE k
newtype N :: forall k. TYPE k where
  MkN :: N -> N

gives

Scratch.hs:35:3: error:
    • A newtype constructor must have a return type of form T a1 ... an
      MkN :: N -> N
    • In the definition of data constructor ‘MkN’
      In the newtype declaration for ‘N’

newtype N :: forall k -> TYPE k where
  MkN :: N m -> N m

gives

Scratch.hs:35:3: error:
    • Expected a type, but ‘N m’ has kind ‘TYPE m’
    • In the definition of data constructor ‘MkN’
      In the newtype declaration for ‘N’

type N :: forall k -> TYPE k
newtype N :: forall k -> TYPE k where
  MkN :: N m -> N m

succeeds.

I think all these examples should succeed. All but the last cause a DEBUG build of GHC to panic.

I think the problem is that the res_kind passed to kcConArgTys has the wrong scope: it mentions variables in the type head, but these are utterly distinct from the variables in the constructor type.

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