From a32eb0f3d5037b0c6fefa38ec19ff8c22076d102 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Thu, 6 May 2021 09:49:45 +0100 Subject: Fix newtype eta-reduction The eta-reduction we do for newype axioms was generating an inhomogeneous axiom: see #19739. This patch fixes it in a simple way; see GHC.Tc.TyCl.Build Note [Newtype eta and homogeneous axioms] --- testsuite/tests/polykinds/T19739a.hs | 11 +++++++++++ testsuite/tests/polykinds/T19739b.hs | 10 ++++++++++ testsuite/tests/polykinds/T19739c.hs | 11 +++++++++++ testsuite/tests/polykinds/T19739d.hs | 12 ++++++++++++ testsuite/tests/polykinds/all.T | 4 ++++ 5 files changed, 48 insertions(+) create mode 100644 testsuite/tests/polykinds/T19739a.hs create mode 100644 testsuite/tests/polykinds/T19739b.hs create mode 100644 testsuite/tests/polykinds/T19739c.hs create mode 100644 testsuite/tests/polykinds/T19739d.hs (limited to 'testsuite') diff --git a/testsuite/tests/polykinds/T19739a.hs b/testsuite/tests/polykinds/T19739a.hs new file mode 100644 index 0000000000..55296b3197 --- /dev/null +++ b/testsuite/tests/polykinds/T19739a.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneKindSignatures #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type T :: forall (a :: Type) -> Constraint +class T a where + f :: Proxy a diff --git a/testsuite/tests/polykinds/T19739b.hs b/testsuite/tests/polykinds/T19739b.hs new file mode 100644 index 0000000000..e0377383da --- /dev/null +++ b/testsuite/tests/polykinds/T19739b.hs @@ -0,0 +1,10 @@ +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneKindSignatures #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type T :: forall (a :: Type) -> Type +newtype T a = Mk (Proxy a) diff --git a/testsuite/tests/polykinds/T19739c.hs b/testsuite/tests/polykinds/T19739c.hs new file mode 100644 index 0000000000..331d1f74fd --- /dev/null +++ b/testsuite/tests/polykinds/T19739c.hs @@ -0,0 +1,11 @@ +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneKindSignatures #-} +module Bug where + +import Data.Kind +import Data.Proxy + +type T :: (forall (x :: Type) -> x) -> forall (a :: Type) -> Type +newtype T f a = MkT (f (Type -> Type) a) diff --git a/testsuite/tests/polykinds/T19739d.hs b/testsuite/tests/polykinds/T19739d.hs new file mode 100644 index 0000000000..e316abf620 --- /dev/null +++ b/testsuite/tests/polykinds/T19739d.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE PolyKinds #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE StandaloneKindSignatures #-} +{-# LANGUAGE TypeFamilies #-} +module Foo where + +import Data.Kind +import Data.Proxy + +type F :: Type -> forall (a :: Type) -> Type +data family F a b +newtype instance F Int b = MkF (Proxy b) diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index 581b065fa9..275281f527 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -236,3 +236,7 @@ test('T19093', normal, compile, ['']) test('T19094', normal, compile, ['']) test('T19250', normal, compile, ['']) test('T19522', normal, compile, ['']) +test('T19739a', normal, compile, ['']) +test('T19739b', normal, compile, ['']) +test('T19739c', normal, compile, ['']) +test('T19739d', normal, compile, ['']) -- cgit v1.2.1