Commit 2f03b216 authored by Bruno BELANYI's avatar Bruno BELANYI

vmmonad: add backwards-compatible MonadFail compliance

The `fail` method on `Monad` has been removed in `ghc` 8.8+, I added a
conditional compilation statement according to what was indicated in the
following wiki article:
<https://gitlab.haskell.org/ghc/ghc/wikis/proposal/monad-fail#adapting-old-code>

* src/VMMonad.hs: Here.
parent eae0f88e
Pipeline #16883 failed with stage
in 46 seconds
{-# LANGUAGE CPP #-}
module VMMonad (Mnd, module VMMonad (Mnd,
run, lift, run, lift,
rfetch, rstore, rpush, rpop, rfetch, rstore, rpush, rpop,
...@@ -24,6 +26,7 @@ import Memory (Memory) ...@@ -24,6 +26,7 @@ import Memory (Memory)
import Annotation (Ann) import Annotation (Ann)
import Opt (OptVal) import Opt (OptVal)
import Control.Monad (ap, liftM) import Control.Monad (ap, liftM)
-- Control.Monad.Fail import has become redundant in GHC 8.8+
import qualified Control.Monad.Fail as Fail import qualified Control.Monad.Fail as Fail
import qualified Cpu (initialize, rfetch, rstore, rpush, rpop) import qualified Cpu (initialize, rfetch, rstore, rpush, rpop)
import qualified Code (initialize, cload, cfind, cstore, cfetch) import qualified Code (initialize, cload, cfind, cstore, cfetch)
...@@ -62,7 +65,10 @@ instance Monad Mnd where ...@@ -62,7 +65,10 @@ instance Monad Mnd where
do x <- c r do x <- c r
case f x of (Mnd c') -> c' r case f x of (Mnd c') -> c' r
fail = Fail.fail #if !(MIN_VERSION_base(4,13,0))
-- Monad(fail) is removed in GHC 8.8+
fail = Fail.fail
#endif
instance Fail.MonadFail Mnd where instance Fail.MonadFail Mnd where
fail = error "fail: invalid pattern matching" fail = error "fail: invalid pattern matching"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment