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,239
    • Issues 5,239
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 566
    • Merge requests 566
  • 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
  • #7176
Closed
Open
Issue created Aug 21, 2012 by Richard Eisenberg@raeDeveloper

Failure to let kind variable remain uninstantiated when not needed

Consider the following code:

{-# LANGUAGE TypeFamilies, DataKinds, PolyKinds, GADTs, RankNTypes #-}

type family Sing (a :: b)

data SMaybe (a :: Maybe c) where
  SNothing :: SMaybe Nothing
  SJust :: Sing a -> SMaybe (Just a)
type instance Sing (a :: Maybe d) = SMaybe a

sIsJust :: forall (a :: Maybe e). Sing a -> ()
sIsJust SNothing = ()
sIsJust (SJust _) = ()

Compiling produces the following error twice on the first part of the type of sIsJust:

    Couldn't match kind `k1' with `e'
      because type variable `e' would escape its scope
    This (rigid, skolem) type variable is bound by
      the type signature for sIsJust :: Sing (Maybe e) a -> ()
    Expected type: Sing (Maybe e) a
      Actual type: SMaybe k1 a

I'm not 100% convinced that this is an error in GHC, but it would seem to me that sIsJust should compile. The explicit quantification is necessary to fix the kind of a, which allows Sing a to simplify to SMaybe a.

My guideline for why this should compile is that the following compiles without complaint:

type family F a
type instance F a = [a]

foo :: F a -> ()
foo [] = ()
foo (_:_) = ()
Trac metadata
Trac field Value
Version 7.6.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking