commit d81a8117a1b31d784f7b98135427863629d7eeca Author: Ryan Scott Date: Fri Mar 15 18:12:23 2019 -0400 Adapt to base-4.13.0.0 diff --git a/Network/Socks5/Parse.hs b/Network/Socks5/Parse.hs index d857274..fe4fd27 100644 --- a/Network/Socks5/Parse.hs +++ b/Network/Socks5/Parse.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE OverloadedStrings #-} @@ -36,6 +37,7 @@ module Network.Socks5.Parse import Control.Applicative import Control.Monad +import qualified Control.Monad.Fail as Fail import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Internal as B (toForeignPtr) @@ -71,10 +73,14 @@ newtype Parser a = Parser { runParser :: forall r . ByteString -> Failure r -> Success a r -> Result r } instance Monad Parser where - fail errorMsg = Parser $ \buf err _ -> err buf ("failed: " ++ errorMsg) +#if !(MIN_VERSION_base(4,13,0)) + fail = Fail.fail +#endif return v = Parser $ \buf _ ok -> ok buf v m >>= k = Parser $ \buf err ok -> runParser m buf err (\buf' a -> runParser (k a) buf' err ok) +instance Fail.MonadFail Parser where + fail errorMsg = Parser $ \buf err _ -> err buf ("failed: " ++ errorMsg) instance MonadPlus Parser where mzero = fail "Parser.MonadPlus.mzero" mplus f g = Parser $ \buf err ok ->