From ff21795a0b9253e811a45626d5686e981ed07f82 Mon Sep 17 00:00:00 2001 From: Simon Peyton Jones Date: Fri, 22 Jan 2016 16:34:18 +0000 Subject: Special-case implicit params in superclass expansion This issue came up in Trac #11480, and is documented in Note [When superclasses help] in TcRnTypes. We were getting a spurious warning T11480.hs:1:1: warning: solveWanteds: too many iterations (limit = 4) The fix is easy. A bit of refactoring along the way. The original bug report in Trac #11480 appears to work fine in HEAD and the 8.0 branch but I added a regression test in this commit as well. --- testsuite/tests/polykinds/T11480a.hs | 26 ++++++++++++++++++++++++++ testsuite/tests/polykinds/all.T | 1 + 2 files changed, 27 insertions(+) create mode 100644 testsuite/tests/polykinds/T11480a.hs (limited to 'testsuite/tests/polykinds') diff --git a/testsuite/tests/polykinds/T11480a.hs b/testsuite/tests/polykinds/T11480a.hs new file mode 100644 index 0000000000..3d17168082 --- /dev/null +++ b/testsuite/tests/polykinds/T11480a.hs @@ -0,0 +1,26 @@ +{-# language KindSignatures, PolyKinds, TypeFamilies, + NoImplicitPrelude, FlexibleContexts, + MultiParamTypeClasses, GADTs, + ConstraintKinds, FlexibleInstances, + FunctionalDependencies, UndecidableSuperClasses #-} + +module T11480a where + +import GHC.Types (Constraint) +import qualified Prelude + +data Nat (c :: i -> i -> *) (d :: j -> j -> *) (f :: i -> j) (g :: i -> j) + +class Functor p (Nat p (->)) p => Category (p :: i -> i -> *) + +class (Category dom, Category cod) + => Functor (dom :: i -> i -> *) (cod :: j -> j -> *) (f :: i -> j) + | f -> dom cod + +instance (Category c, Category d) => Category (Nat c d) +instance (Category c, Category d) => Functor (Nat c d) (Nat (Nat c d) (->)) (Nat c d) +instance (Category c, Category d) => Functor (Nat c d) (->) (Nat c d f) + +instance Category (->) +instance Functor (->) (->) ((->) e) +instance Functor (->) (Nat (->) (->)) (->) diff --git a/testsuite/tests/polykinds/all.T b/testsuite/tests/polykinds/all.T index f1f25cecc4..69c5ba0790 100644 --- a/testsuite/tests/polykinds/all.T +++ b/testsuite/tests/polykinds/all.T @@ -134,3 +134,4 @@ test('T11278', normal, compile, ['']) test('T11255', normal, compile, ['']) test('T11459', normal, compile_fail, ['']) test('T11466', normal, compile_fail, ['']) +test('T11480a', normal, compile, ['']) -- cgit v1.2.1