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,243
    • Issues 5,243
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 570
    • Merge requests 570
  • 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
  • #10514
Closed
Open
Issue created Jun 12, 2015 by andreas.abel@trac-andreas.abel

Generic for existential types

I have some use for Generic for an existential type which is constraint to be Generic.

{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE StandaloneDeriving #-}

import GHC.Generics

data U = forall a. (Generic a) => U a
  deriving (Generic)  -- TRY 1
    -- Can't make a derived instance of ‘Generic U’:
    --   Constructor ‘U’ has existentials or constraints in its type
    --   Possible fix: use a standalone deriving declaration instead

deriving instance Generic U -- TRY 2
    -- Can't make a derived instance of ‘Generic U’:
    --   U must be a vanilla data constructor
    -- In the stand-alone deriving instance for ‘Generic U’

data D1Ser
data C1_0Ser

instance Generic U where -- TRY 3
  type Rep U = D D1Ser (C1 C1_0Ser (S1 NoSelector (Rep a)))
    -- Not in scope: type variable ‘a’

-- How to bring the existential type `a' into scope?
Edited Mar 10, 2019 by andreas.abel
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking