diff options
author | Artem Pelenitsyn <a.pelenitsyn@gmail.com> | 2022-01-23 22:59:08 +0100 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2022-03-05 01:06:47 -0500 |
commit | 6f84ee332fd243e83004bdbc92a6970e96ab3189 (patch) | |
tree | a79a465d0116805da7e5b10c4d72534cd66705e9 | |
parent | 3570eda512d157a38da391b6f1d57dfbab72dd09 (diff) | |
download | haskell-6f84ee332fd243e83004bdbc92a6970e96ab3189.tar.gz |
remove MonadFail instances of ST
CLC proposal: https://github.com/haskell/core-libraries-committee/issues/33
The instances had `fail` implemented in terms of `error`, whereas the
idea of the `MonadFail` class is that the `fail` method should be
implemented in terms of the monad itself.
-rw-r--r-- | libraries/base/Control/Monad/ST/Lazy/Imp.hs | 4 | ||||
-rw-r--r-- | libraries/base/GHC/ST.hs | 5 | ||||
-rw-r--r-- | libraries/base/changelog.md | 5 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T4175.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/monadfail/MonadFailErrors.hs | 7 | ||||
-rw-r--r-- | testsuite/tests/monadfail/MonadFailErrors.stderr | 2 |
6 files changed, 7 insertions, 18 deletions
diff --git a/libraries/base/Control/Monad/ST/Lazy/Imp.hs b/libraries/base/Control/Monad/ST/Lazy/Imp.hs index 888839132e..e67daf9dd1 100644 --- a/libraries/base/Control/Monad/ST/Lazy/Imp.hs +++ b/libraries/base/Control/Monad/ST/Lazy/Imp.hs @@ -190,10 +190,6 @@ instance Monad (ST s) where in unST (k r) new_s --- | @since 4.10 -instance MonadFail (ST s) where - fail s = errorWithoutStackTrace s - -- | Return the value computed by an 'ST' computation. -- The @forall@ ensures that the internal state used by the 'ST' -- computation is inaccessible to the rest of the program. diff --git a/libraries/base/GHC/ST.hs b/libraries/base/GHC/ST.hs index 98ba18b3d8..27749e83bb 100644 --- a/libraries/base/GHC/ST.hs +++ b/libraries/base/GHC/ST.hs @@ -26,7 +26,6 @@ module GHC.ST ( import GHC.Base import GHC.Show -import Control.Monad.Fail default () @@ -79,10 +78,6 @@ instance Monad (ST s) where (k2 new_s) }}) -- | @since 4.11.0.0 -instance MonadFail (ST s) where - fail s = errorWithoutStackTrace s - --- | @since 4.11.0.0 instance Semigroup a => Semigroup (ST s a) where (<>) = liftA2 (<>) diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index a905e2d2f3..ed12f00737 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -43,6 +43,11 @@ CPtrdiff, CSize, CWchar, CSigAtomic, CLLong, CULLong, CBool, CIntPtr, CUIntPtr, CIntMax, CUIntMax. + * Remove instances of `MonadFail` for the `ST` monad (lazy and strict) as per + the [Core Libraries proposal](https://github.com/haskell/core-libraries-committee/issues/33). + A [migration guide](https://github.com/haskell/core-libraries-committee/blob/main/guides/no-monadfail-st-inst.md) + is available. + ## 4.16.0.0 *Nov 2021* diff --git a/testsuite/tests/ghci/scripts/T4175.stdout b/testsuite/tests/ghci/scripts/T4175.stdout index 7b7423ec6e..91a1fbb881 100644 --- a/testsuite/tests/ghci/scripts/T4175.stdout +++ b/testsuite/tests/ghci/scripts/T4175.stdout @@ -41,10 +41,10 @@ type Maybe :: * -> * data Maybe a = Nothing | Just a -- Defined in ‘GHC.Maybe’ instance Traversable Maybe -- Defined in ‘Data.Traversable’ +instance MonadFail Maybe -- Defined in ‘Control.Monad.Fail’ instance Foldable Maybe -- Defined in ‘Data.Foldable’ instance Applicative Maybe -- Defined in ‘GHC.Base’ instance Functor Maybe -- Defined in ‘GHC.Base’ -instance MonadFail Maybe -- Defined in ‘Control.Monad.Fail’ instance Monad Maybe -- Defined in ‘GHC.Base’ instance Semigroup a => Monoid (Maybe a) -- Defined in ‘GHC.Base’ instance Semigroup a => Semigroup (Maybe a) diff --git a/testsuite/tests/monadfail/MonadFailErrors.hs b/testsuite/tests/monadfail/MonadFailErrors.hs index 008a0b2c16..733f923a15 100644 --- a/testsuite/tests/monadfail/MonadFailErrors.hs +++ b/testsuite/tests/monadfail/MonadFailErrors.hs @@ -37,13 +37,6 @@ io = do -st :: ST s a -st = do - Just x <- undefined - undefined - - - reader :: r -> a reader = do Just x <- undefined diff --git a/testsuite/tests/monadfail/MonadFailErrors.stderr b/testsuite/tests/monadfail/MonadFailErrors.stderr index 285e6fb4e0..ac2af1e10d 100644 --- a/testsuite/tests/monadfail/MonadFailErrors.stderr +++ b/testsuite/tests/monadfail/MonadFailErrors.stderr @@ -33,7 +33,7 @@ MonadFailErrors.hs:28:5: error: = do Just x <- undefined undefined -MonadFailErrors.hs:49:5: error: +MonadFailErrors.hs:42:5: error: • No instance for (MonadFail ((->) r)) arising from a do statement with the failable pattern ‘Just x’ |