[commit: packages/binary] master: Define MonadFail instance for Get Monad (a9df926)
git at git.haskell.org
git at git.haskell.org
Tue Feb 2 21:05:00 UTC 2016
Repository : ssh://git@git.haskell.org/binary
On branch : master
Link : http://git.haskell.org/packages/binary.git/commitdiff/a9df926504a66b8059783727956929b6643dc9fc
>---------------------------------------------------------------
commit a9df926504a66b8059783727956929b6643dc9fc
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date: Tue Feb 2 21:20:00 2016 +0100
Define MonadFail instance for Get Monad
>---------------------------------------------------------------
a9df926504a66b8059783727956929b6643dc9fc
binary.cabal | 4 ++--
src/Data/Binary/Get/Internal.hs | 8 ++++++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/binary.cabal b/binary.cabal
index 477f933..a5eeb9c 100644
--- a/binary.cabal
+++ b/binary.cabal
@@ -53,8 +53,8 @@ library
ghc-options: -O2 -Wall -fliberate-case-threshold=1000
- if impl(ghc >= 7.11)
- ghc-options: -Wcompat -Wnoncanonical-monad-instances
+ if impl(ghc >= 8.0)
+ ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
-- Due to circular dependency, we cannot make any of the test-suites or
-- benchmark depend on the binary library. Instead, for each test-suite and
diff --git a/src/Data/Binary/Get/Internal.hs b/src/Data/Binary/Get/Internal.hs
index 10e372f..944a2ce 100644
--- a/src/Data/Binary/Get/Internal.hs
+++ b/src/Data/Binary/Get/Internal.hs
@@ -48,6 +48,9 @@ import qualified Data.ByteString.Unsafe as B
import Control.Applicative
import Control.Monad
+#if MIN_VERSION_base(4,9,0)
+import qualified Control.Monad.Fail as Fail
+#endif
import Data.Binary.Internal ( accursedUnutterablePerformIO )
@@ -94,6 +97,11 @@ type Success a r = B.ByteString -> a -> Decoder r
instance Monad Get where
return = pure
(>>=) = bindG
+#if MIN_VERSION_base(4,9,0)
+ fail = Fail.fail
+
+instance Fail.MonadFail Get where
+#endif
fail = failG
bindG :: Get a -> (a -> Get b) -> Get b
More information about the ghc-commits
mailing list