diff --git a/Network/Socks5/Command.hs b/Network/Socks5/Command.hs
--- a/Network/Socks5/Command.hs
+++ b/Network/Socks5/Command.hs
@@ -1,5 +1,6 @@
 {-# LANGUAGE DeriveDataTypeable #-}
 {-# LANGUAGE ViewPatterns #-}
+{-# LANGUAGE CPP #-}
 -- |
 -- Module      : Network.Socks5.Command
 -- License     : BSD-style
@@ -96,7 +97,11 @@
 -- but might not be a good idea for multi messages from one party.
 runGetDone :: Serialize a => Get a -> IO ByteString -> IO a
 runGetDone getter ioget = ioget >>= return . runGetPartial getter >>= r where
+#if MIN_VERSION_cereal(0,4,0)
+    r (Fail s _)     = error s
+#else
     r (Fail s)       = error s
+#endif
     r (Partial cont) = ioget >>= r . cont
     r (Done a b)
         | not $ B.null b = error "got too many bytes while receiving data"
diff --git a/socks.cabal b/socks.cabal
--- a/socks.cabal
+++ b/socks.cabal
@@ -1,5 +1,5 @@
 Name:                socks
-Version:             0.5.1
+Version:             0.5.2
 Description:         Socks proxy (version 5) implementation.
 License:             BSD3
 License-file:        LICENSE
