summaryrefslogtreecommitdiff
path: root/testsuite/tests/warnings/should_compile/T22151.hs
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/tests/warnings/should_compile/T22151.hs')
-rw-r--r--testsuite/tests/warnings/should_compile/T22151.hs16
1 files changed, 16 insertions, 0 deletions
diff --git a/testsuite/tests/warnings/should_compile/T22151.hs b/testsuite/tests/warnings/should_compile/T22151.hs
new file mode 100644
index 0000000000..aa30b07e5f
--- /dev/null
+++ b/testsuite/tests/warnings/should_compile/T22151.hs
@@ -0,0 +1,16 @@
+{-# LANGUAGE UndecidableInstances #-}
+module T22151 where
+
+import Control.Monad.IO.Class (MonadIO(liftIO))
+
+class (Applicative m, Monad m) => C m where
+ m :: m ()
+
+-- This should not emit a -Wredundant-constraints warning. This is because
+-- GHC should not expand the superclasses of the Given constraint `MonadIO m`
+-- given that it is not Paterson-smaller than the instance head `C m`. (See
+-- Note [Recursive superclasses] in GHC.Tc.TyCl.Instance for more on what
+-- "Paterson-smaller" means.) As a result, we must provide the `Applicative m`
+-- and `Monad m` constraints explicitly.
+instance (Applicative m, Monad m, MonadIO m) => C m where
+ m = liftIO (pure ())