diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2017-09-09 16:29:23 +0200 |
---|---|---|
committer | Herbert Valerio Riedel <hvr@gnu.org> | 2017-09-09 16:43:36 +0200 |
commit | 346e562adffd44edd8c31328c0280543d7dd75c1 (patch) | |
tree | e10042e1640a8ad944c86d8590c45bb02254d2f6 /compiler/utils | |
parent | dab0e515eadecaee3e9e9f5f8eee3159fa39bb27 (diff) | |
download | haskell-346e562adffd44edd8c31328c0280543d7dd75c1.tar.gz |
Canonicalise MonoidFail instances in GHC
IOW, code compiles -Wnoncanonical-monoidfail-instances clean now
This is easy now since we require GHC 8.0/base-4.9 or later
for bootstrapping.
Note that we can easily enable `MonadFail` via
default-extensions: MonadFailDesugaring
in compiler/ghc.cabal.in
which currently would point out that NatM doesn't have
a proper `fail` method, even though failable patterns
are made use of:
compiler/nativeGen/SPARC/CodeGen.hs:425:25: error:
* No instance for (Control.Monad.Fail.MonadFail NatM)
arising from a do statement
with the failable pattern ‘(dyn_c, [dyn_r])’
Diffstat (limited to 'compiler/utils')
-rw-r--r-- | compiler/utils/IOEnv.hs | 2 | ||||
-rw-r--r-- | compiler/utils/ListT.hs | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/compiler/utils/IOEnv.hs b/compiler/utils/IOEnv.hs index 5a7ccd9972..6fc5f9dc67 100644 --- a/compiler/utils/IOEnv.hs +++ b/compiler/utils/IOEnv.hs @@ -56,7 +56,7 @@ unIOEnv (IOEnv m) = m instance Monad (IOEnv m) where (>>=) = thenM (>>) = (*>) - fail _ = failM -- Ignore the string + fail = MonadFail.fail instance MonadFail.MonadFail (IOEnv m) where fail _ = failM -- Ignore the string diff --git a/compiler/utils/ListT.hs b/compiler/utils/ListT.hs index 2b81db1ed4..7dc1aa3eaf 100644 --- a/compiler/utils/ListT.hs +++ b/compiler/utils/ListT.hs @@ -32,6 +32,7 @@ module ListT ( import Control.Applicative import Control.Monad +import Control.Monad.Fail as MonadFail ------------------------------------------------------------------------- -- | A monad transformer for performing backtracking computations @@ -64,6 +65,9 @@ instance Alternative (ListT f) where instance Monad (ListT m) where m >>= f = ListT $ \sk fk -> unListT m (\a fk' -> unListT (f a) sk fk') fk + fail = MonadFail.fail + +instance MonadFail (ListT m) where fail _ = ListT $ \_ fk -> fk instance MonadPlus (ListT m) where |