diff options
author | Ben Gamari <ben@smart-cactus.org> | 2019-03-04 14:38:03 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2019-03-04 14:38:03 -0500 |
commit | 79e4524cd27eb0da0e3e3f69c5373468da58afad (patch) | |
tree | ffad3b07b0488ff8295b2c8ab252ffe920151f76 | |
parent | 69e85a9a971425741e96cb41bebad8bd4221b97f (diff) | |
download | haskell-wip/final-mfp.tar.gz |
More testsuite thingswip/final-mfp
23 files changed, 34 insertions, 296 deletions
diff --git a/testsuite/tests/deSugar/should_run/dsrun010.hs b/testsuite/tests/deSugar/should_run/dsrun010.hs index 1d4fc485e0..c11fa2a765 100644 --- a/testsuite/tests/deSugar/should_run/dsrun010.hs +++ b/testsuite/tests/deSugar/should_run/dsrun010.hs @@ -2,13 +2,11 @@ -- is reflected by calling the monadic 'fail', not by a -- runtime exception -{-# LANGUAGE NoMonadFailDesugaring #-} -{-# OPTIONS -Wno-missing-monadfail-instances #-} - import Control.Monad +import Control.Monad.Fail import Data.Maybe -test :: (MonadPlus m) => [a] -> m Bool +test :: (MonadPlus m, MonadFail m) => [a] -> m Bool test xs = do (_:_) <- return xs diff --git a/testsuite/tests/determinism/determ017/A.hs b/testsuite/tests/determinism/determ017/A.hs index 5e3c3d0809..082c9380de 100644 --- a/testsuite/tests/determinism/determ017/A.hs +++ b/testsuite/tests/determinism/determ017/A.hs @@ -20,7 +20,7 @@ -- | Module "Trampoline" defines the pipe computations and their basic building blocks. {-# LANGUAGE ScopedTypeVariables, Rank2Types, MultiParamTypeClasses, - TypeFamilies, KindSignatures, FlexibleContexts, NoMonadFailDesugaring, + TypeFamilies, KindSignatures, FlexibleContexts, FlexibleInstances, OverlappingInstances, UndecidableInstances #-} @@ -81,6 +81,9 @@ instance Monad Identity where return a = Identity a m >>= k = k (runIdentity m) +instance MonadFail Identity where + fail = error "Identity(fail)" + newtype Trampoline m s r = Trampoline {bounce :: m (TrampolineState m s r)} data TrampolineState m s r = Done r | Suspend! (s (Trampoline m s r)) @@ -97,6 +100,9 @@ instance (Monad m, Functor s) => Monad (Trampoline m s) where where apply f (Done x) = bounce (f x) apply f (Suspend s) = return (Suspend (fmap (>>= f) s)) +instance (MonadFail m, Functor s) => MonadFail (Trampoline m s) where + fail = error "Trampoline(fail)" + data Yield x y = Yield! x y instance Functor (Yield x) where fmap f (Yield x y) = trace "fmap yield" $ Yield x (f y) 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/all.T b/testsuite/tests/monadfail/all.T index 32eddb9e98..c718e91eef 100644 --- a/testsuite/tests/monadfail/all.T +++ b/testsuite/tests/monadfail/all.T @@ -1,4 +1,3 @@ test('MonadFailWarnings', normal, compile, ['']) test('MonadFailErrors', normal, compile_fail, ['']) -test('MonadFailWarningsDisabled', normal, compile, ['']) test('MonadFailWarningsWithRebindableSyntax', normal, compile, ['']) diff --git a/testsuite/tests/perf/compiler/T3064.hs b/testsuite/tests/perf/compiler/T3064.hs index dacca79296..e29dd95564 100644 --- a/testsuite/tests/perf/compiler/T3064.hs +++ b/testsuite/tests/perf/compiler/T3064.hs @@ -19,6 +19,8 @@ instance (Monad m) => Monad (ReaderT r m) where m >>= k = ReaderT $ \r -> do a <- runReaderT m r runReaderT (k a) r + +instance (MonadFail m) => MonadFail (ReaderT r m) where fail msg = ReaderT $ \_ -> fail msg newtype ResourceT r s m v = ResourceT { unResourceT :: ReaderT r m v } diff --git a/testsuite/tests/programs/galois_raytrace/Eval.hs b/testsuite/tests/programs/galois_raytrace/Eval.hs index 001842edad..250c4c4afb 100644 --- a/testsuite/tests/programs/galois_raytrace/Eval.hs +++ b/testsuite/tests/programs/galois_raytrace/Eval.hs @@ -33,7 +33,6 @@ instance Applicative Pure where instance Monad Pure where Pure x >>= k = k x return = pure - fail s = error s instance MonadEval Pure where doOp = doPureOp @@ -306,6 +305,8 @@ instance Monad Abs where AbsState r s' -> runAbs (k r) s' AbsFail m -> AbsFail m) return = pure + +instance MonadFail Abs where fail s = Abs (\ n -> AbsFail s) instance MonadEval Abs where diff --git a/testsuite/tests/quasiquotation/qq005/Expr.hs b/testsuite/tests/quasiquotation/qq005/Expr.hs index 1c51d9db1f..767d906ba4 100644 --- a/testsuite/tests/quasiquotation/qq005/Expr.hs +++ b/testsuite/tests/quasiquotation/qq005/Expr.hs @@ -64,7 +64,7 @@ anti = lexeme $ cs <- many idchar return $ AntiIntExpr (c : cs) -parseExpr :: Monad m => TH.Loc -> String -> m Expr +parseExpr :: MonadFail m => TH.Loc -> String -> m Expr parseExpr (Loc {loc_filename = file, loc_start = (line,col)}) s = case runParser p () "" s of Left err -> fail $ show err diff --git a/testsuite/tests/quasiquotation/qq006/Expr.hs b/testsuite/tests/quasiquotation/qq006/Expr.hs index 1c51d9db1f..767d906ba4 100644 --- a/testsuite/tests/quasiquotation/qq006/Expr.hs +++ b/testsuite/tests/quasiquotation/qq006/Expr.hs @@ -64,7 +64,7 @@ anti = lexeme $ cs <- many idchar return $ AntiIntExpr (c : cs) -parseExpr :: Monad m => TH.Loc -> String -> m Expr +parseExpr :: MonadFail m => TH.Loc -> String -> m Expr parseExpr (Loc {loc_filename = file, loc_start = (line,col)}) s = case runParser p () "" s of Left err -> fail $ show err diff --git a/testsuite/tests/rebindable/DoRestrictedM.hs b/testsuite/tests/rebindable/DoRestrictedM.hs index 4f7885783e..de28079769 100644 --- a/testsuite/tests/rebindable/DoRestrictedM.hs +++ b/testsuite/tests/rebindable/DoRestrictedM.hs @@ -30,10 +30,11 @@ m1 >> m2 = m1 >>= (const m2) newtype RegularM m a = RegularM{unRM :: m a} -instance Prelude.Monad m => MN2 (RegularM m) a where +instance Prelude.MonadFail m => MN2 (RegularM m) a where return = RegularM . Prelude.return + fail = fail -instance Prelude.Monad m => MN3 (RegularM m) a b where +instance Prelude.MonadFail m => MN3 (RegularM m) a b where m >>= f = RegularM ((Prelude.>>=) (unRM m) (unRM . f)) -- We try to inject Maybe (as the regular monad) into Restricted Monad diff --git a/testsuite/tests/rebindable/rebindable2.hs b/testsuite/tests/rebindable/rebindable2.hs index 9fe15150f4..3858d2b9f3 100644 --- a/testsuite/tests/rebindable/rebindable2.hs +++ b/testsuite/tests/rebindable/rebindable2.hs @@ -8,7 +8,7 @@ module Main where import Prelude(String,undefined,Maybe(..),IO,putStrLn, Integer,(++),Rational, (==), (>=) ); - import Prelude(Monad(..),Applicative(..),Functor(..)); + import Prelude(Monad(..),Applicative(..),Functor(..),MonadFail(..)); import Control.Monad(ap, liftM); debugFunc :: String -> IO a -> IO a; @@ -35,7 +35,9 @@ module Main where (>>=) ma amb = MkTM (debugFunc ">>=" ((Prelude.>>=) (unTM ma) (\a -> unTM (amb a)))); (>>) ma mb = MkTM (debugFunc ">>" ((Prelude.>>) (unTM ma) (unTM mb))); - + }; + instance (MonadFail TM) where + { fail s = MkTM (debugFunc "fail" (Prelude.return undefined)); }; diff --git a/testsuite/tests/simplCore/prog002/Simpl009Help.hs b/testsuite/tests/simplCore/prog002/Simpl009Help.hs index e4c6df351e..b64639ec8a 100644 --- a/testsuite/tests/simplCore/prog002/Simpl009Help.hs +++ b/testsuite/tests/simplCore/prog002/Simpl009Help.hs @@ -28,9 +28,6 @@ instance Monad (Parser s) where Parser f >>= k = Parser (\fut -> f (\a -> let Parser g = k a in g fut)) - fail s = - Parser (\fut exp -> Fail exp [s]) - instance Alternative (Parser s) where empty = mzero (<|>) = mplus diff --git a/testsuite/tests/simplCore/should_compile/T8331.hs b/testsuite/tests/simplCore/should_compile/T8331.hs index 04cb1aff73..a7dc318826 100644 --- a/testsuite/tests/simplCore/should_compile/T8331.hs +++ b/testsuite/tests/simplCore/should_compile/T8331.hs @@ -23,6 +23,8 @@ instance (Monad m) => Monad (ReaderT r m) where m >>= k = ReaderT $ \ r -> do a <- runReaderT m r runReaderT (k a) r + +instance MonadFail m => MonadFail (ReaderT r m) where fail msg = ReaderT (\_ -> fail msg) mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b diff --git a/testsuite/tests/typecheck/should_compile/T4524.hs b/testsuite/tests/typecheck/should_compile/T4524.hs index 669c4b268a..fbdc0cd77c 100644 --- a/testsuite/tests/typecheck/should_compile/T4524.hs +++ b/testsuite/tests/typecheck/should_compile/T4524.hs @@ -174,6 +174,8 @@ instance Monad Perhaps where (Succeeded _) >> k = k Unknown >> k = k return = Succeeded + +instance MonadFail Perhaps where fail _ = Unknown instance Alternative Perhaps where diff --git a/testsuite/tests/typecheck/should_compile/T4969.hs b/testsuite/tests/typecheck/should_compile/T4969.hs index 6a087974c7..b8332bdcba 100644 --- a/testsuite/tests/typecheck/should_compile/T4969.hs +++ b/testsuite/tests/typecheck/should_compile/T4969.hs @@ -89,7 +89,6 @@ instance Applicative (TCMT m) where instance Monad (TCMT m) where return = undefined (>>=) = undefined - fail = undefined instance Monad m => MonadIO (TCMT m) where diff --git a/testsuite/tests/typecheck/should_compile/Tc239_Help.hs b/testsuite/tests/typecheck/should_compile/Tc239_Help.hs index 4f39612e4e..1718c99088 100644 --- a/testsuite/tests/typecheck/should_compile/Tc239_Help.hs +++ b/testsuite/tests/typecheck/should_compile/Tc239_Help.hs @@ -20,4 +20,3 @@ instance Monad (WrapIO e) where m >>= f = MkWrapIO (do x <- unwrap m unwrap (f x) ) - fail str = error str
\ No newline at end of file diff --git a/testsuite/tests/typecheck/should_run/T1735_Help/State.hs b/testsuite/tests/typecheck/should_run/T1735_Help/State.hs index 44078ae944..093a7e2c81 100644 --- a/testsuite/tests/typecheck/should_run/T1735_Help/State.hs +++ b/testsuite/tests/typecheck/should_run/T1735_Help/State.hs @@ -11,7 +11,9 @@ instance Monad m => Monad (StateT s m) where m >>= k = StateT $ \s -> do ~(a, s') <- runStateT m s runStateT (k a) s' - fail str = StateT $ \_ -> fail str + +instance MonadFail m => MonadFail (StateT s m) where + fail s = StateT $ \_ -> fail s instance Monad m => Functor (StateT s m) where fmap = liftM diff --git a/testsuite/tests/warnings/should_compile/T11128.hs b/testsuite/tests/warnings/should_compile/T11128.hs deleted file mode 100644 index 23725c1e4b..0000000000 --- a/testsuite/tests/warnings/should_compile/T11128.hs +++ /dev/null @@ -1,50 +0,0 @@ -{-# LANGUAGE DeriveFunctor #-} -{-# OPTIONS_GHC -fwarn-noncanonical-monad-instances #-} - --- | Test noncanonical-monad-instances warnings -module T11128 where - -import Control.Applicative as A -import Control.Monad as M - ----------------------------------------------------------------------------- --- minimal definition - -data T0 a = T0 a deriving Functor - -instance A.Applicative T0 where - pure = T0 - (<*>) = M.ap - -instance M.Monad T0 where - (>>=) = undefined - ----------------------------------------------------------------------------- --- trigger all 4 warnings - -data T1 a = T1 a deriving Functor - -instance A.Applicative T1 where - pure = return - (<*>) = M.ap - (*>) = (M.>>) - -instance M.Monad T1 where - (>>=) = undefined - return = T1 - (>>) = undefined - ----------------------------------------------------------------------------- --- backward compat canonical definition - -data T2 a = T2 a deriving Functor - -instance Applicative T2 where - pure = T2 - (<*>) = ap - (*>) = undefined - -instance M.Monad T2 where - (>>=) = undefined - return = pure - (>>) = (*>) diff --git a/testsuite/tests/warnings/should_compile/T11128.stderr b/testsuite/tests/warnings/should_compile/T11128.stderr deleted file mode 100644 index b8d788236c..0000000000 --- a/testsuite/tests/warnings/should_compile/T11128.stderr +++ /dev/null @@ -1,20 +0,0 @@ - -T11128.hs:28:5: warning: [-Wnoncanonical-monad-instances] - Noncanonical ‘pure = return’ definition detected - in the instance declaration for ‘Applicative T1’. - Move definition from ‘return’ to ‘pure’ - -T11128.hs:30:5: warning: [-Wnoncanonical-monad-instances] - Noncanonical ‘(*>) = (>>)’ definition detected - in the instance declaration for ‘Applicative T1’. - Move definition from ‘(>>)’ to ‘(*>)’ - -T11128.hs:34:5: warning: [-Wnoncanonical-monad-instances] - Noncanonical ‘return’ definition detected - in the instance declaration for ‘Monad T1’. - Either remove definition for ‘return’ or define as ‘return = pure’ - -T11128.hs:35:5: warning: [-Wnoncanonical-monad-instances] - Noncanonical ‘(>>)’ definition detected - in the instance declaration for ‘Monad T1’. - Either remove definition for ‘(>>)’ or define as ‘(>>) = (*>)’ diff --git a/testsuite/tests/warnings/should_compile/T11128b.hs b/testsuite/tests/warnings/should_compile/T11128b.hs deleted file mode 100644 index 497927716c..0000000000 --- a/testsuite/tests/warnings/should_compile/T11128b.hs +++ /dev/null @@ -1,64 +0,0 @@ -{-# LANGUAGE DeriveFunctor #-} -{-# OPTIONS_GHC -Wnoncanonical-monadfail-instances #-} - --- | Test noncanonical-monadfail-instances warnings -module T11128b where - -import Control.Applicative as A -import Control.Monad as M -import Control.Monad.Fail as MF - ----------------------------------------------------------------------------- --- minimal definition - -data T0 a = T0 a deriving Functor - -instance A.Applicative T0 where - pure = T0 - (<*>) = M.ap - -instance M.Monad T0 where - (>>=) = undefined - -instance MF.MonadFail T0 where - fail = error "fail" - ----------------------------------------------------------------------------- --- trigger all 2 warnings - -data T1 a = T1 a deriving Functor - -instance A.Applicative T1 where - pure = return - (<*>) = M.ap - (*>) = (M.>>) - -instance M.Monad T1 where - (>>=) = undefined - return = T1 - (>>) = undefined - fail = error "fail" - -instance MF.MonadFail T1 where - fail = M.fail - ----------------------------------------------------------------------------- --- backward compat canonical definition - -data T2 a = T2 a deriving Functor - -instance Applicative T2 where - pure = T2 - (<*>) = ap - (*>) = undefined - -instance M.Monad T2 where - (>>=) = undefined - return = pure - (>>) = (*>) - fail = MF.fail - -instance MF.MonadFail T2 where - fail = error "fail" - ----------------------------------------------------------------------------- diff --git a/testsuite/tests/warnings/should_compile/T11128b.stderr b/testsuite/tests/warnings/should_compile/T11128b.stderr deleted file mode 100644 index e3fd3e83dc..0000000000 --- a/testsuite/tests/warnings/should_compile/T11128b.stderr +++ /dev/null @@ -1,10 +0,0 @@ - -T11128b.hs:40:5: warning: [-Wnoncanonical-monadfail-instances] - Noncanonical ‘fail’ definition detected - in the instance declaration for ‘Monad T1’. - Either remove definition for ‘fail’ or define as ‘fail = Control.Monad.Fail.fail’ - -T11128b.hs:43:5: warning: [-Wnoncanonical-monadfail-instances] - Noncanonical ‘fail = Control.Monad.fail’ definition detected - in the instance declaration for ‘MonadFail T1’. - Move definition from ‘Control.Monad.fail’ to ‘fail’ diff --git a/testsuite/tests/warnings/should_compile/all.T b/testsuite/tests/warnings/should_compile/all.T index 10a3ecf12c..36e6b1beeb 100644 --- a/testsuite/tests/warnings/should_compile/all.T +++ b/testsuite/tests/warnings/should_compile/all.T @@ -9,8 +9,6 @@ test('T10908', normal, compile, ['']) test('T10930', normal, compile, ['']) test('T10930b', normal, compile, ['']) test('T11077', normal, compile, ['-fwarn-missing-exported-signatures']) -test('T11128', normal, compile, ['']) -test('T11128b', normal, compile, ['']) test('T13256', normal, compile, ['']) test('T15460', normal, compile, ['']) test('PluralS', normal, compile, ['']) diff --git a/testsuite/tests/wcompat-warnings/Template.hs b/testsuite/tests/wcompat-warnings/Template.hs index 03f9a4957e..798eafc787 100644 --- a/testsuite/tests/wcompat-warnings/Template.hs +++ b/testsuite/tests/wcompat-warnings/Template.hs @@ -1,14 +1,9 @@ -{-# LANGUAGE NoMonadFailDesugaring, KindSignatures #-} +{-# LANGUAGE KindSignatures #-} module WCompatWarningsOnOff where import qualified Data.Semigroup as Semi -monadFail :: Monad m => m a -monadFail = do - Just _ <- undefined - undefined - (<>) = undefined -- Semigroup warnings -- -fwarn-noncanonical-monoid-instances diff --git a/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr b/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr index 3c3e73ddf6..b0d7bb2636 100644 --- a/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr +++ b/testsuite/tests/wcompat-warnings/WCompatWarningsOn.stderr @@ -1,40 +1,19 @@ -Template.hs:9:5: warning: [-Wmissing-monadfail-instances (in -Wcompat)] - • Could not deduce (Control.Monad.Fail.MonadFail m) - arising from the failable pattern ‘Just _’ - (this will become an error in a future GHC release) - from the context: Monad m - bound by the type signature for: - monadFail :: forall (m :: * -> *) a. Monad m => m a - at Template.hs:7:1-27 - Possible fix: - add (Control.Monad.Fail.MonadFail m) to the context of - the type signature for: - monadFail :: forall (m :: * -> *) a. Monad m => m a - • In a stmt of a 'do' block: Just _ <- undefined - In the expression: - do Just _ <- undefined - undefined - In an equation for ‘monadFail’: - monadFail - = do Just _ <- undefined - undefined - -Template.hs:12:1: warning: [-Wsemigroup (in -Wcompat)] +Template.hs:7:1: warning: [-Wsemigroup (in -Wcompat)] Local definition of ‘<>’ clashes with a future Prelude name. This will become an error in a future release. -Template.hs:18:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)] +Template.hs:13:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)] Noncanonical ‘(<>) = mappend’ definition detected in the instance declaration for ‘Semigroup S’. Move definition from ‘mappend’ to ‘(<>)’ -Template.hs:21:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)] +Template.hs:16:3: warning: [-Wnoncanonical-monoid-instances (in -Wcompat)] Noncanonical ‘mappend’ definition detected in the instance declaration for ‘Monoid S’. Define as ‘mappend = (<>)’ -Template.hs:25:15: warning: [-Wstar-is-type (in -Wcompat)] +Template.hs:20:15: warning: [-Wstar-is-type (in -Wcompat)] Using ‘*’ (or its Unicode variant) to mean ‘Data.Kind.Type’ relies on the StarIsType extension, which will become deprecated in the future. |