Commit 87b2d4d1 authored by Lennart Kolmodin's avatar Lennart Kolmodin
Browse files

Merge pull request #104 from hvr/pr/monadfail-cpp

Define MonadFail instance for Get Monad
parents 13820f45 a9df9265
......@@ -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
......
......@@ -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
......
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