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,252
    • Issues 5,252
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 577
    • Merge requests 577
  • 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
  • #19728
Closed (duplicated) (duplicated)
Open
Issue created Apr 22, 2021 by Ryan Scott@RyanGlScottMaintainer

GHC 9.0+ fails to combine levity-polymorphic newtype constructor with TypeApplications

GHC 8.10.4 has no problem typechecking this program:

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE UnliftedNewtypes #-}
module Bug where

import GHC.Exts

type Id :: TYPE r -> TYPE r
newtype Id a where
  MkId :: forall r (a :: TYPE r). a -> Id a

idBool :: Id Bool
idBool = MkId @LiftedRep @Bool True

However, GHC 9.0.1 and later fail with:

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

Bug.hs:17:10: error:
    • Cannot apply expression of type ‘a0 -> Id a0’
      to a visible type argument ‘LiftedRep’
    • In the expression: MkId @LiftedRep @Bool True
      In an equation for ‘idBool’: idBool = MkId @LiftedRep @Bool True
   |
17 | idBool = MkId @LiftedRep @Bool True
   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^

As far as I can tell, this program should be expected to typecheck, so I believe this is a regression.

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