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,268
    • Issues 4,268
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 408
    • Merge Requests 408
  • 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
  • #8177

Closed
Open
Opened Aug 27, 2013 by Simon Peyton Jones@simonpjDeveloper

Roles for type families

Now that we have roles, it might be helpful to be able to give a role signature for a data/type family.

At the moment, data/type family constructors have all parameters conservatively assigned to be role N. Thus

data family D a    -- Parameter conservatively assumed to be N

class C a where
  op :: D a -> a

instance C Int where ....

newtype N a = MkN a deriving( C )  -- Rejected

The generalised-newtype-deriving clause deriving( C ) is rejected because D might use its parameter at role N thus:

data instance D [b] = MkD (F b)   -- F is a type function

It would be strictly more expressive if we could

  • Declare the roles of D's arguments (as we can declare their kinds). E.g.
data family D a@R
  • Check that each family instance obeys that role signature. E.g. given the preceding role signature, reject this instance:
data instance D [b] = MkD (F b)   -- F is a type function

I think there is no technical difficulty here. Just a question of doing it.

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