Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,262
    • Issues 4,262
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Issues
  • #16024

Closed
Open
Opened Dec 10, 2018 by Andrew Martin@andrewthadDeveloper

Kind Signatures on data instances

There's a comment in compiler/typecheck/TcInstDcls.hs that reads:

The "header" is the part other than the data constructors themselves

e.g. data instance D [a] :: * -> * = ...

Here the "header" is the bit before the "=" sign

What's weird is that you cannot actually compile code that this example suggests is valid. Consider this:

{-# language TypeFamilies #-}
  
module BadSig where

data family Bar a :: *
data instance Bar Int :: * = Bool

It fails on GHC 8.6.2 with:

bad_sig.hs:6:28: error:
    parse error on input ‘=’
    Perhaps you need a 'let' in a 'do' block?
    e.g. 'let x = 5' instead of 'x = 5'
  |
6 | data instance Bar Int :: * = Bool
  |                            ^

Oddly, GHC will accept the instance if the body is missing:

{-# language TypeFamilies #-}
  
module BadSig where

data family Bar a :: *
data instance Bar Int :: *

It is not clear to me whether or not this one should be accepted, but that is beside the point. The first example should certainly be accepted. It should also be accepted with TYPE 'LiftedRep instead of *, but it fails with the same parser error when given that kind signature as well.

Trac metadata
Trac field Value
Version 8.6.2
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Assignee
Assign to
8.6.3
Milestone
8.6.3
Assign milestone
Time tracking
None
Due date
None
Reference: ghc/ghc#16024