Conditionally exclude 'fail' for Program, Invariant, and STM

This commit is contained in:
Michael Walker 2019-10-03 16:17:59 +01:00
parent 732bce8f7b
commit b8005defd5
3 changed files with 26 additions and 4 deletions

View File

@ -7,6 +7,15 @@ standard Haskell versioning scheme.
.. _PVP: https://pvp.haskell.org/
unreleased
----------
Miscellaneous
~~~~~~~~~~~~~
* Fixed a compilation error with GHC 8.8
2.1.0.0 (2019-03-24)
--------------------

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE RankNTypes #-}
@ -8,7 +9,7 @@
-- License : MIT
-- Maintainer : Michael Walker <mike@barrucadu.co.uk>
-- Stability : experimental
-- Portability : ExistentialQuantification, GADTs, RankNTypes
-- Portability : CPP, ExistentialQuantification, GADTs, RankNTypes
--
-- Common types and utility functions for deterministic execution of
-- 'MonadConc' implementations. This module is NOT considered to form
@ -95,9 +96,13 @@ instance (pty ~ Basic) => Applicative (Program pty n) where
instance (pty ~ Basic) => Monad (Program pty n) where
return = pure
fail = Fail.fail
m >>= k = ModelConc $ \c -> runModelConc m (\x -> runModelConc (k x) c)
#if MIN_VERSION_base(4,13,0)
#else
fail = Fail.fail
#endif
instance (pty ~ Basic) => Fail.MonadFail (Program pty n) where
fail e = ModelConc $ \_ -> AThrow (MonadFailException e)
@ -243,9 +248,13 @@ instance Applicative (Invariant n) where
instance Monad (Invariant n) where
return = pure
fail = Fail.fail
m >>= k = Invariant $ \c -> runInvariant m (\x -> runInvariant (k x) c)
#if MIN_VERSION_base(4,13,0)
#else
fail = Fail.fail
#endif
instance Fail.MonadFail (Invariant n) where
fail e = Invariant $ \_ -> IThrow (MonadFailException e)

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TypeFamilies #-}
@ -11,7 +12,7 @@
-- License : MIT
-- Maintainer : Michael Walker <mike@barrucadu.co.uk>
-- Stability : experimental
-- Portability : ExistentialQuantification, NoMonoLocalBinds, RecordWildCards, TypeFamilies
-- Portability : CPP, ExistentialQuantification, NoMonoLocalBinds, RecordWildCards, TypeFamilies
--
-- 'MonadSTM' testing implementation, internal types and definitions.
-- This module is NOT considered to form part of the public interface
@ -51,7 +52,10 @@ instance Monad (ModelSTM n) where
return = pure
m >>= k = ModelSTM $ \c -> runModelSTM m (\x -> runModelSTM (k x) c)
#if MIN_VERSION_base(4,13,0)
#else
fail = Fail.fail
#endif
instance Fail.MonadFail (ModelSTM n) where
fail e = ModelSTM $ \_ -> SThrow (MonadFailException e)