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,246
    • Issues 5,246
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 564
    • Merge requests 564
  • 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
  • #8758
Closed
Open
Issue created Feb 09, 2014 by Richard Eisenberg@raeDeveloper

GeneralizedNewtypeDeriving sometimes needs RankNTypes

Consider

{-# LANGUAGE RankNTypes #-}

module A where

class C m where
  foo :: (forall b. b -> m b) -> c -> m c

instance C [] where
  foo f c = f c

and

{-# LANGUAGE GeneralizedNewtypeDeriving #-}

module B where

import A

newtype MyList a = Mk [a]
  deriving C

When I compile B.hs, I get

    Illegal polymorphic or qualified type: forall b. b -> MyList b
    Perhaps you intended to use RankNTypes or Rank2Types
    In an expression type signature:
      forall (c :: *). (forall (b :: *). b -> MyList b) -> c -> MyList c
    In the expression:
        GHC.Prim.coerce
          (foo :: (forall (b :: *). b -> [] b) -> c -> [] c) ::
          forall (c :: *). (forall (b :: *). b -> MyList b) -> c -> MyList c
    In an equation for ‛foo’:
        foo
          = GHC.Prim.coerce
              (foo :: (forall (b :: *). b -> [] b) -> c -> [] c) ::
              forall (c :: *). (forall (b :: *). b -> MyList b) -> c -> MyList c

I will fix shortly.

Trac metadata
Trac field Value
Version 7.8.1-rc1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler (Type checker)
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking