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,273
    • Issues 4,273
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 413
    • Merge Requests 413
  • 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
  • #6036

Closed
Open
Opened Apr 23, 2012 by Richard Eisenberg@raeDeveloper

Kind generalization fails in data family instance GADT

The following code fails to compile:

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

data family Sing (a :: k)

data instance Sing (a :: Maybe k) where
  SNothing :: Sing 'Nothing
  SJust :: Sing b -> Sing ('Just b)

The error is

    Data constructor `SNothing' returns type `Sing
                                                (Maybe k0) ('Nothing k0)'
      instead of an instance of its parent type `Sing (Maybe k) a'
    In the definition of data constructor `SNothing'
    In the data instance declaration for `Sing'

It seems that the k kind parameter is not being allowed to generalize over other kind parameters. The following (seemingly equivalent) formulation compiles:

{-# LANGUAGE ..., ExistentialQuantification #-}

data instance Sing (a :: Maybe k) =
    a ~ 'Nothing => SNothing
  | forall b. a ~ 'Just b => SJust (Sing b)

This was tested on 7.5.20120420.

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