Opened 2 months ago

Closed 2 months ago

#8758 closed bug (fixed)

GeneralizedNewtypeDeriving sometimes needs RankNTypes

Reported by: goldfire Owned by: goldfire
Priority: normal Milestone: 7.8.1
Component: Compiler (Type checker) Version: 7.8.1-rc1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: deriving/should_compile/T8758 Blocked By:
Blocking: Related Tickets:

Description

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.

Change History (4)

comment:1 Changed 2 months ago by Richard Eisenberg <eir@…>

In 8cc398ff8b3f7408327d99347f440693cb204c0a/ghc:

Fix #8758 by assuming RankNTypes when checking GND code.

comment:2 Changed 2 months ago by goldfire

  • Status changed from new to merge
  • Test Case set to deriving/should_compile/T8758

comment:3 Changed 2 months ago by thoughtpolice

  • Milestone set to 7.8.1

comment:4 Changed 2 months ago by thoughtpolice

  • Resolution set to fixed
  • Status changed from merge to closed

Merged.

Note: See TracTickets for help on using tickets.