summaryrefslogtreecommitdiff
path: root/testsuite/tests/monadfail
diff options
context:
space:
mode:
authorHerbert Valerio Riedel <hvr@gnu.org>2018-11-10 01:12:52 +0100
committerBen Gamari <ben@smart-cactus.org>2019-03-22 10:34:51 -0400
commitab51bee40c82cd552bcf13e24b67d43f3b8d25f3 (patch)
treea75a4102576dad50af44e342fb9152e7270792eb /testsuite/tests/monadfail
parentcd07086ada34888c08585f4dc98a961618748ed0 (diff)
downloadhaskell-ab51bee40c82cd552bcf13e24b67d43f3b8d25f3.tar.gz
base: Remove `Monad(fail)` method and reexport `MonadFail(fail)` instead
As per https://prime.haskell.org/wiki/Libraries/Proposals/MonadFail Coauthored-by: Ben Gamari <ben@well-typed.com>
Diffstat (limited to 'testsuite/tests/monadfail')
-rw-r--r--testsuite/tests/monadfail/MonadFailErrors.hs2
-rw-r--r--testsuite/tests/monadfail/MonadFailErrors.stderr8
-rw-r--r--testsuite/tests/monadfail/MonadFailWarnings.hs107
-rw-r--r--testsuite/tests/monadfail/MonadFailWarnings.stderr47
-rw-r--r--testsuite/tests/monadfail/MonadFailWarningsDisabled.hs100
-rw-r--r--testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.hs14
-rw-r--r--testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.stderr5
-rw-r--r--testsuite/tests/monadfail/all.T3
8 files changed, 4 insertions, 282 deletions
diff --git a/testsuite/tests/monadfail/MonadFailErrors.hs b/testsuite/tests/monadfail/MonadFailErrors.hs
index f9db31e5a0..008a0b2c16 100644
--- a/testsuite/tests/monadfail/MonadFailErrors.hs
+++ b/testsuite/tests/monadfail/MonadFailErrors.hs
@@ -1,8 +1,6 @@
-- Test purpose:
-- Break properly if MonadFail is live
-{-# LANGUAGE MonadFailDesugaring #-}
-
module MonadFailWarnings where
import Control.Monad.Fail
diff --git a/testsuite/tests/monadfail/MonadFailErrors.stderr b/testsuite/tests/monadfail/MonadFailErrors.stderr
index 27fc3c3cf5..285e6fb4e0 100644
--- a/testsuite/tests/monadfail/MonadFailErrors.stderr
+++ b/testsuite/tests/monadfail/MonadFailErrors.stderr
@@ -1,12 +1,12 @@
-MonadFailErrors.hs:16:5: error:
+MonadFailErrors.hs:14:5: error:
• Could not deduce (MonadFail m)
arising from a do statement
with the failable pattern ‘Just x’
from the context: Monad m
bound by the type signature for:
general :: forall (m :: * -> *) a. Monad m => m a
- at MonadFailErrors.hs:14:1-25
+ at MonadFailErrors.hs:12:1-25
Possible fix:
add (MonadFail m) to the context of
the type signature for:
@@ -20,7 +20,7 @@ MonadFailErrors.hs:16:5: error:
= do Just x <- undefined
undefined
-MonadFailErrors.hs:30:5: error:
+MonadFailErrors.hs:28:5: error:
• No instance for (MonadFail Identity)
arising from a do statement
with the failable pattern ‘Just x’
@@ -33,7 +33,7 @@ MonadFailErrors.hs:30:5: error:
= do Just x <- undefined
undefined
-MonadFailErrors.hs:51:5: error:
+MonadFailErrors.hs:49:5: error:
• No instance for (MonadFail ((->) r))
arising from a do statement
with the failable pattern ‘Just x’
diff --git a/testsuite/tests/monadfail/MonadFailWarnings.hs b/testsuite/tests/monadfail/MonadFailWarnings.hs
deleted file mode 100644
index 7e3d7fc428..0000000000
--- a/testsuite/tests/monadfail/MonadFailWarnings.hs
+++ /dev/null
@@ -1,107 +0,0 @@
--- Test purpose:
--- Ensure that MonadFail warnings are issued correctly if the warning flag
--- is enabled
-{-# LANGUAGE NoMonadFailDesugaring #-}
-{-# OPTIONS_GHC -Wmissing-monadfail-instances -Wno-error=compat #-}
-
-module MonadFailWarnings where
-
-import Control.Monad.Fail
-import Control.Monad.ST
-import Data.Functor.Identity
-
-
-
--- should warn, because the do-block gets a general Monad constraint,
--- but should have MonadFail
-general :: Monad m => m a
-general = do
- Just x <- undefined
- undefined
-
-
-
--- should NOT warn, because the constraint is correct
-general' :: MonadFail m => m a
-general' = do
- Just x <- undefined
- undefined
-
-
-
--- should warn, because Identity isn't MonadFail
-identity :: Identity a
-identity = do
- Just x <- undefined
- undefined
-
-
-
--- should NOT warn, because IO is MonadFail
-io :: IO a
-io = do
- Just x <- undefined
- undefined
-
-
-
--- should warn, because (ST s) is not MonadFail
-st :: ST s a
-st = do
- Just x <- undefined
- undefined
-
-
-
--- should warn, because (r ->) is not MonadFail
-reader :: r -> a
-reader = do
- Just x <- undefined
- undefined
-
-
-
--- should NOT warn, because matching against newtype
-newtype Newtype a = Newtype a
-newtypeMatch :: Identity a
-newtypeMatch = do
- Newtype x <- undefined
- undefined
-
-
-
--- should NOT warn, because Data has only one constructor
-data Data a = Data a
-singleConMatch :: Identity a
-singleConMatch = do
- Data x <- undefined
- undefined
-
-
-
--- should NOT warn, because Maybe' has a MonadFail instance
-data Maybe' a = Nothing' | Just' a
-instance Functor Maybe' where fmap = undefined
-instance Applicative Maybe' where pure = undefined; (<*>) = undefined
-instance Monad Maybe' where (>>=) = undefined
-instance MonadFail Maybe' where fail = undefined
-customFailable :: Maybe' a
-customFailable = do
- Just x <- undefined
- undefined
-
-
--- should NOT warn, because patterns always match
-wildcardx, explicitlyIrrefutable, wildcard_, tuple :: Monad m => m a
-wildcardx = do
- x <- undefined
- undefined
-explicitlyIrrefutable = do
- ~(x:y) <- undefined
- undefined
-wildcard_ = do
- _ <- undefined
- undefined
-tuple = do
- (a,b) <- undefined
- undefined
diff --git a/testsuite/tests/monadfail/MonadFailWarnings.stderr b/testsuite/tests/monadfail/MonadFailWarnings.stderr
deleted file mode 100644
index 7a341fc816..0000000000
--- a/testsuite/tests/monadfail/MonadFailWarnings.stderr
+++ /dev/null
@@ -1,47 +0,0 @@
-
-MonadFailWarnings.hs:19:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
- • Could not deduce (MonadFail m)
- arising from the failable pattern ‘Just x’
- (this will become an error in a future GHC release)
- from the context: Monad m
- bound by the type signature for:
- general :: forall (m :: * -> *) a. Monad m => m a
- at MonadFailWarnings.hs:17:1-25
- Possible fix:
- add (MonadFail m) to the context of
- the type signature for:
- general :: forall (m :: * -> *) a. Monad m => m a
- • In a stmt of a 'do' block: Just x <- undefined
- In the expression:
- do Just x <- undefined
- undefined
- In an equation for ‘general’:
- general
- = do Just x <- undefined
- undefined
-
-MonadFailWarnings.hs:35:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
- • No instance for (MonadFail Identity)
- arising from the failable pattern ‘Just x’
- (this will become an error in a future GHC release)
- • In a stmt of a 'do' block: Just x <- undefined
- In the expression:
- do Just x <- undefined
- undefined
- In an equation for ‘identity’:
- identity
- = do Just x <- undefined
- undefined
-
-MonadFailWarnings.hs:59:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
- • No instance for (MonadFail ((->) r))
- arising from the failable pattern ‘Just x’
- (this will become an error in a future GHC release)
- • In a stmt of a 'do' block: Just x <- undefined
- In the expression:
- do Just x <- undefined
- undefined
- In an equation for ‘reader’:
- reader
- = do Just x <- undefined
- undefined
diff --git a/testsuite/tests/monadfail/MonadFailWarningsDisabled.hs b/testsuite/tests/monadfail/MonadFailWarningsDisabled.hs
deleted file mode 100644
index 858a212b45..0000000000
--- a/testsuite/tests/monadfail/MonadFailWarningsDisabled.hs
+++ /dev/null
@@ -1,100 +0,0 @@
--- Test purpose:
--- Make sure that not enabling MonadFail warnings makes code compile just
--- as it did in < 8.0
-
--- NOTE: starting w/ GHC 8.6 sugaring is turned on by default; so we have
--- to disable to keep supporting this test-case
---
-{-# LANGUAGE NoMonadFailDesugaring #-}
-{-# OPTIONS -Wno-missing-monadfail-instances #-}
-
-module MonadFailWarnings where
-
-import Control.Monad.Fail
-import Control.Monad.ST
-import Data.Functor.Identity
-
-
-
-general :: Monad m => m a
-general = do
- Just x <- undefined
- undefined
-
-
-
-general' :: MonadFail m => m a
-general' = do
- Just x <- undefined
- undefined
-
-
-
-identity :: Identity a
-identity = do
- Just x <- undefined
- undefined
-
-
-
-io :: IO a
-io = do
- Just x <- undefined
- undefined
-
-
-
-st :: ST s a
-st = do
- Just x <- undefined
- undefined
-
-
-
-reader :: r -> a
-reader = do
- Just x <- undefined
- undefined
-
-
-
-newtype Newtype a = Newtype a
-newtypeMatch :: Identity a
-newtypeMatch = do
- Newtype x <- undefined
- undefined
-
-
-
-data Data a = Data a
-singleConMatch :: Identity a
-singleConMatch = do
- Data x <- undefined
- undefined
-
-
-
-data Maybe' a = Nothing' | Just' a
-instance Functor Maybe' where fmap = undefined
-instance Applicative Maybe' where pure = undefined; (<*>) = undefined
-instance Monad Maybe' where (>>=) = undefined
-instance MonadFail Maybe' where fail = undefined
-customFailable :: Maybe' a
-customFailable = do
- Just x <- undefined
- undefined
-
-
-wildcardx, explicitlyIrrefutable, wildcard_, tuple :: Monad m => m a
-wildcardx = do
- x <- undefined
- undefined
-explicitlyIrrefutable = do
- ~(x:y) <- undefined
- undefined
-wildcard_ = do
- _ <- undefined
- undefined
-tuple = do
- (a,b) <- undefined
- undefined
diff --git a/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.hs b/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.hs
deleted file mode 100644
index b369fc019f..0000000000
--- a/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.hs
+++ /dev/null
@@ -1,14 +0,0 @@
--- Test purpose:
--- RebindableSyntax does not play that well with MonadFail, so here we ensure
--- that when both settings are enabled we get the proper warning.
-
-{-# OPTIONS_GHC -Wmissing-monadfail-instances -Wno-error=compat #-}
-{-# LANGUAGE RebindableSyntax #-}
-
-module MonadFailWarningsWithRebindableSyntax where
-
-import Prelude
-
-test1 f g = do
- Just x <- f
- g
diff --git a/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.stderr b/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.stderr
deleted file mode 100644
index 7b6cd1ba6d..0000000000
--- a/testsuite/tests/monadfail/MonadFailWarningsWithRebindableSyntax.stderr
+++ /dev/null
@@ -1,5 +0,0 @@
-
-MonadFailWarningsWithRebindableSyntax.hs:13:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)]
- The failable pattern ‘Just x’
- is used together with -XRebindableSyntax. If this is intentional,
- compile with -Wno-missing-monadfail-instances.
diff --git a/testsuite/tests/monadfail/all.T b/testsuite/tests/monadfail/all.T
index 32eddb9e98..8fde0296dc 100644
--- a/testsuite/tests/monadfail/all.T
+++ b/testsuite/tests/monadfail/all.T
@@ -1,4 +1 @@
-test('MonadFailWarnings', normal, compile, [''])
test('MonadFailErrors', normal, compile_fail, [''])
-test('MonadFailWarningsDisabled', normal, compile, [''])
-test('MonadFailWarningsWithRebindableSyntax', normal, compile, [''])