diff options
author | David Luposchainsky <dluposchainsky@gmail.com> | 2015-11-17 17:10:02 +0100 |
---|---|---|
committer | Ben Gamari <bgamari.foss@gmail.com> | 2015-11-17 12:29:09 -0500 |
commit | 233d1312bf15940fca5feca6884f965e7944b555 (patch) | |
tree | 0f787688562e65c1043626d8d03447ef2ab0b7a7 /testsuite/tests/rebindable | |
parent | 7b962bab384e2ae85b41d30f503c3d0295b0214f (diff) | |
download | haskell-233d1312bf15940fca5feca6884f965e7944b555.tar.gz |
MonadFail proposal, phase 1
This implements phase 1 of the MonadFail proposal (MFP, #10751).
- MonadFail warnings are all issued as desired, tunable with two new flags
- GHC was *not* made warning-free with `-fwarn-missing-monadfail-warnings`
(but it's disabled by default right now)
Credits/thanks to
- Franz Thoma, whose help was crucial to implementing this
- My employer TNG Technology Consulting GmbH for partially funding us
for this work
Reviewers: goldfire, austin, #core_libraries_committee, hvr, bgamari, fmthoma
Reviewed By: hvr, bgamari, fmthoma
Subscribers: thomie
Projects: #ghc
Differential Revision: https://phabricator.haskell.org/D1248
GHC Trac Issues: #10751
Diffstat (limited to 'testsuite/tests/rebindable')
-rw-r--r-- | testsuite/tests/rebindable/rebindable1.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/rebindable/rebindable6.hs | 21 | ||||
-rw-r--r-- | testsuite/tests/rebindable/rebindable6.stderr | 24 |
3 files changed, 28 insertions, 24 deletions
diff --git a/testsuite/tests/rebindable/rebindable1.hs b/testsuite/tests/rebindable/rebindable1.hs index 1fb0b596fb..7bf3e237a6 100644 --- a/testsuite/tests/rebindable/rebindable1.hs +++ b/testsuite/tests/rebindable/rebindable1.hs @@ -1,3 +1,4 @@ +{-# OPTIONS_GHC -fno-warn-missing-monadfail-instance #-} {-# LANGUAGE RebindableSyntax, NPlusKPatterns #-} module RebindableCase1 where @@ -11,7 +12,7 @@ module RebindableCase1 where infixl 1 >>=; (>>=) :: a; (>>=) = undefined; - + infixl 1 >>; (>>) :: a; (>>) = undefined; @@ -38,9 +39,9 @@ module RebindableCase1 where Just a <- g; return a; }; - + test_fromInteger = 1; - + test_fromRational = 0.5; test_negate a = - a; diff --git a/testsuite/tests/rebindable/rebindable6.hs b/testsuite/tests/rebindable/rebindable6.hs index ffd69f904b..ec975e7f37 100644 --- a/testsuite/tests/rebindable/rebindable6.hs +++ b/testsuite/tests/rebindable/rebindable6.hs @@ -1,15 +1,18 @@ -{-# LANGUAGE RebindableSyntax, NPlusKPatterns, RankNTypes, - ScopedTypeVariables, FlexibleInstances #-} +{-# LANGUAGE RebindableSyntax #-} +{-# LANGUAGE NPlusKPatterns #-} +{-# LANGUAGE RankNTypes #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE FlexibleInstances #-} + module Main where { --- import Prelude; import qualified Prelude; import Prelude(String,undefined,Maybe(..),IO,putStrLn, Integer,(++),Rational, (==), (>=) ); debugFunc :: String -> IO a -> IO a; debugFunc s ioa = (putStrLn ("++ " ++ s)) Prelude.>> - (ioa Prelude.>>= (\a -> + (ioa Prelude.>>= (\a -> (putStrLn ("-- " ++ s)) Prelude.>> (Prelude.return a) )); @@ -18,7 +21,7 @@ module Main where returnIO :: a -> IO a; returnIO = Prelude.return; - + class HasReturn a where { return :: a; @@ -107,10 +110,10 @@ module Main where Just (b::b) <- g; -- >>= (and fail if g returns Nothing) return b; -- return }; - + test_fromInteger :: Integer; test_fromInteger = 27; - + test_fromRational :: Rational; test_fromRational = 31.5; @@ -129,7 +132,7 @@ module Main where doTest :: String -> IO a -> IO (); - doTest s ioa = + doTest s ioa = (putStrLn ("start test " ++ s)) Prelude.>> ioa @@ -137,7 +140,7 @@ module Main where (putStrLn ("end test " ++ s)); main :: IO (); - main = + main = (doTest "test_do failure" (test_do (Prelude.return ()) (Prelude.return Nothing)) ) diff --git a/testsuite/tests/rebindable/rebindable6.stderr b/testsuite/tests/rebindable/rebindable6.stderr index cf280a961d..269ea8ff05 100644 --- a/testsuite/tests/rebindable/rebindable6.stderr +++ b/testsuite/tests/rebindable/rebindable6.stderr @@ -1,18 +1,18 @@ -rebindable6.hs:106:17: error: +rebindable6.hs:109:17: error: Ambiguous type variable ‘t0’ arising from a do statement prevents the constraint ‘(HasSeq (IO a -> t0 -> IO b))’ from being solved. (maybe you haven't applied a function to enough arguments?) Relevant bindings include - g :: IO (Maybe b) (bound at rebindable6.hs:104:19) - f :: IO a (bound at rebindable6.hs:104:17) + g :: IO (Maybe b) (bound at rebindable6.hs:107:19) + f :: IO a (bound at rebindable6.hs:107:17) test_do :: IO a -> IO (Maybe b) -> IO b - (bound at rebindable6.hs:104:9) + (bound at rebindable6.hs:107:9) Probable fix: use a type annotation to specify what ‘t0’ should be. These potential instance exist: instance HasSeq (IO a -> IO b -> IO b) - -- Defined at rebindable6.hs:52:18 + -- Defined at rebindable6.hs:55:18 In a stmt of a 'do' block: f In the expression: do { f; @@ -24,7 +24,7 @@ rebindable6.hs:106:17: error: Just (b :: b) <- g; return b } -rebindable6.hs:107:17: error: +rebindable6.hs:110:17: error: Ambiguous type variable ‘t1’ arising from a do statement prevents the constraint ‘(HasFail ([Char] -> t1))’ from being solved. @@ -32,7 +32,7 @@ rebindable6.hs:107:17: error: Probable fix: use a type annotation to specify what ‘t1’ should be. These potential instance exist: instance HasFail (String -> IO a) - -- Defined at rebindable6.hs:57:18 + -- Defined at rebindable6.hs:60:18 In a stmt of a 'do' block: Just (b :: b) <- g In the expression: do { f; @@ -44,18 +44,18 @@ rebindable6.hs:107:17: error: Just (b :: b) <- g; return b } -rebindable6.hs:108:17: error: +rebindable6.hs:111:17: error: Ambiguous type variable ‘t1’ arising from a use of ‘return’ prevents the constraint ‘(HasReturn (b -> t1))’ from being solved. (maybe you haven't applied a function to enough arguments?) Relevant bindings include - b :: b (bound at rebindable6.hs:107:23) - g :: IO (Maybe b) (bound at rebindable6.hs:104:19) + b :: b (bound at rebindable6.hs:110:23) + g :: IO (Maybe b) (bound at rebindable6.hs:107:19) test_do :: IO a -> IO (Maybe b) -> IO b - (bound at rebindable6.hs:104:9) + (bound at rebindable6.hs:107:9) Probable fix: use a type annotation to specify what ‘t1’ should be. These potential instance exist: - instance HasReturn (a -> IO a) -- Defined at rebindable6.hs:42:18 + instance HasReturn (a -> IO a) -- Defined at rebindable6.hs:45:18 In a stmt of a 'do' block: return b In the expression: do { f; |