Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • 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,829
    • Issues 4,829
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 446
    • Merge requests 446
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #19487

Closed
Open
Created Mar 04, 2021 by Sebastian Graf@sgraf812Developer

Relax Note [Phantom type variables in kinds] to allow for phantom levity vars

While implementing the unlifted datatypes proposal (!2218 (closed)), I realised that an edge case violates the kinding rules (Note [Phantom type variables in kinds], in particular). Specifically

type T :: forall (l :: Levity). TYPE (BoxedRep l)
data T = MkT

Note that

  1. T has a nullary data con MkT
  2. T is levity-polymorphic

That means the type of MkT, forall {l::Levity}. T @l, is ill-kinded! We have T @l :: TYPE (BoxedRep l) and the forall is supposed to bind the l. But the kind rule for forall a. TYPE rep demands that a is not free in rep:

          ty : TYPE rep
          `a` is not free in rep
(FORALL1) -----------------------
          forall a. ty : TYPE rep

I argue that there is no harm in allowing TYPE (BoxedRep l) here, because l does not affect the representation of T. I'm unaware of any other implications this might have.

We have to be a bit careful with evaluation semantics, but we have better means (#15532 (comment 239845), #17521) to decide whether levity polymorphism is OK at the term level. In any instance, MkT is a data constructor and thus is a value under both call-by-need and call-by-value semantics. I'm reasonably positive that allowing MkT to be well-kinded is OK. You can't do anything with it at the term level unless you apply it to a Levity anyway.

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