diff --git a/Network/TLS/Core.hs b/Network/TLS/Core.hs
--- a/Network/TLS/Core.hs
+++ b/Network/TLS/Core.hs
@@ -72,13 +72,16 @@
 recvData :: MonadIO m => Context -> m B.ByteString
 recvData ctx = liftIO $ do
     checkValid ctx
-    E.catchJust (\Error_EOF -> Just ())
+    E.catchJust safeHandleError_EOF
                 doRecv
                 (\() -> return B.empty)
   where doRecv = do
             pkt <- withReadLock ctx $ recvPacket ctx
             either onError process pkt
-
+            
+        safeHandleError_EOF Error_EOF = Just ()
+        safeHandleError_EOF _ = Nothing
+        
         onError err@(Error_Protocol (reason,fatal,desc)) =
             terminate err (if fatal then AlertLevel_Fatal else AlertLevel_Warning) desc reason
         onError err =
diff --git a/Network/TLS/Record/State.hs b/Network/TLS/Record/State.hs
--- a/Network/TLS/Record/State.hs
+++ b/Network/TLS/Record/State.hs
@@ -23,6 +23,7 @@
     ) where
 
 import Data.Word
+import Control.Applicative
 import Control.Monad.State
 import Control.Monad.Error
 import Network.TLS.Compression
@@ -56,6 +57,10 @@
 newtype RecordM a = RecordM { runRecordM :: Version
                                          -> RecordState
                                          -> Either TLSError (a, RecordState) }
+
+instance Applicative RecordM where
+    pure = return
+    (<*>) = ap
 
 instance Monad RecordM where
     return a  = RecordM $ \_ st  -> Right (a, st)
diff --git a/tls.cabal b/tls.cabal
--- a/tls.cabal
+++ b/tls.cabal
@@ -1,5 +1,5 @@
 Name:                tls
-Version:             1.2.6
+Version:             1.2.7
 Description:
    Native Haskell TLS and SSL protocol implementation for server and client.
    .
