diff options
author | Zubin Duggal <zubin.duggal@gmail.com> | 2022-05-31 13:08:05 +0530 |
---|---|---|
committer | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2022-08-31 20:45:09 +0200 |
commit | 269884b8e233d0f629783f327e9b8af11e612252 (patch) | |
tree | 39b99f5d7d430551fe49565c3a654d84bee4378a | |
parent | 7f490b1333c17ed27b213d6af8c7275aa9b3de63 (diff) | |
download | haskell-wip/21550-test.tar.gz |
Add regression test for #21550wip/21550-test
This was fixed by ca90ffa321a31842a32be1b5b6e26743cd677ec5
"Use local instances with least superclass depth"
-rw-r--r-- | testsuite/tests/typecheck/should_compile/T21550.hs | 39 | ||||
-rw-r--r-- | testsuite/tests/typecheck/should_compile/all.T | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/testsuite/tests/typecheck/should_compile/T21550.hs b/testsuite/tests/typecheck/should_compile/T21550.hs new file mode 100644 index 0000000000..4248a1f533 --- /dev/null +++ b/testsuite/tests/typecheck/should_compile/T21550.hs @@ -0,0 +1,39 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE DeriveGeneric #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE KindSignatures #-} +{-# LANGUAGE QuantifiedConstraints #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE UndecidableInstances #-} + +module Main where + +import Data.Function +import Data.Kind +import GHC.Generics +import GHC.TypeLits + +-- inlined generic-data imports: +from' :: Generic a => a -> Rep a () +from' = from + +geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool +geq = (==) `on` from' + +gcompare :: (Generic a, Ord (Rep a ())) => a -> a -> Ordering +gcompare = compare `on` from' + + +-- test case: +data A (v :: Symbol -> Type -> Type) a b deriving (Generic,Generic1) + +instance (Eq a , (forall w z . Eq z => Eq (v w z)) , Eq b) => Eq (A v a b) where + {-# INLINE (==) #-} + (==) = geq + +instance (Ord a , (forall w z . Eq z => Eq (v w z)) , (forall w z . Ord z => Ord (v w z)) , Ord b) => Ord (A v a b) where + {-# INLINE compare #-} + compare = gcompare + +main :: IO () +main = pure () diff --git a/testsuite/tests/typecheck/should_compile/all.T b/testsuite/tests/typecheck/should_compile/all.T index dae6e5bca7..802eb9097d 100644 --- a/testsuite/tests/typecheck/should_compile/all.T +++ b/testsuite/tests/typecheck/should_compile/all.T @@ -855,3 +855,4 @@ test('DeepSubsumption08', normal, compile, ['']) test('DeepSubsumption09', normal, compile, ['']) test('T21951a', normal, compile, ['-Wredundant-strictness-flags']) test('T21951b', normal, compile, ['-Wredundant-strictness-flags']) +test('T21550', normal, compile, ['']) |