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,334
    • Issues 4,334
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 369
    • Merge Requests 369
  • 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
  • #12245

Closed
Open
Opened Jun 29, 2016 by Simon Peyton Jones@simonpjDeveloper

Deriving Data at higher kinds

Here's what Lennart Spitzner wanted to do:

> {-# LANGUAGE StandaloneDeriving #-}
> {-# LANGUAGE DeriveDataTypeable #-}
> {-# LANGUAGE FlexibleInstances #-}
> 
> import Data.Data ( Data )
>
> data Foo f = Foo (f Bool) (f Int)
> 
> deriving instance Data (Foo [])
> deriving instance Data (Foo Maybe)

Of course you can't derive Data for Foo because we don't know what f is, so Lennart is making multiple instances, one for each instance of f. It's a bit clumsy. What we would really like is

deriving instance (forall a. Data  => Data (f a)) => Data (Foo f)

but we don't have higher order instances yet! So Lennart is manually making two instances.

This should work, but he gets

> Main.hs: line 45, column 1:
>   Multiple declarations of ‘$cr2C’
>     Declared at: Main.hs:44:1
>                  Main.hs:45:1
> Main.hs: line 45, column 1:
>   Multiple declarations of ‘$tr2D’
>     Declared at: Main.hs:44:1
>                  Main.hs:45:1
Trac metadata
Trac field Value
Version 8.0.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
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#12245