Skip to content

Can't write type signature for top-level polymorphic pattern binding

Hi,

In GHC 7.4.1 and 7.6.3 I can't write a type signature for a top-level polymorphic pattern binding. Consider this program:

{-# LANGUAGE RankNTypes #-}

newtype T = T (forall t. t -> t)

tf :: T
tf = T id

-- Can't write this type signature:
-- f :: t -> t
T f = tf

-- But with an indirection we can:
g :: t -> t
g = f

-- We can still use f as it were fully polymorphic (which is good):
a :: ()
a = f ()
b :: Char
b = f 'b'

I expect to be able to specify a type for f.

The same applies for a data family constructor, which is my original use case. I don't think it matters much, but here is an similar test case that uses a data family:

{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeFamilies #-}

class C t where
  data F t :: *
  mkF :: t -> F t

instance C () where
  data F () = FUnit (forall t. t -> t)
  mkF () = FUnit id

-- Can't write a type for f here either:
FUnit f = mkF ()
Trac metadata
Trac field Value
Version 7.6.3
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