Opened 5 years ago

Closed 5 years ago

#9195 closed bug (invalid)

ImpredicativeTypes and ConstraintKinds don't interact as expected

Reported by: MikeIzbicki Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.8.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHC rejects valid program Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:

Description

Given this code:

{-# LANGUAGE MultiParamTypeClasses, FlexibleInstances, ImpredicativeTypes, ConstraintKinds #-}

class P a b
instance P a b

type Test a = forall b. P a b

I would expect to be able to actually use the Test Constraint in a function, like so:

foo :: Test a => a -> a
foo = id

But GHC complains that:

    Illegal polymorphic or qualified type: Test a
    In the type signature for ‘foo’: foo :: Test a => a -> a

I get the exact same error message if I replace ImpredicativeTypes with RankNTypes. If this is intended behavior under ImpredicativeTypes, how difficult would it be to add another extension that allows this type of polymorphism?

Change History (2)

comment:1 Changed 5 years ago by monoidal

AFAIK polymorphic constraints are not supported. See comment at #7019.

comment:2 Changed 5 years ago by rwbarton

Resolution: invalid
Status: newclosed

Indeed. See also the feature request #2893.

Note: See TracTickets for help on using tickets.