diff --git a/hasql.cabal b/hasql.cabal
--- a/hasql.cabal
+++ b/hasql.cabal
@@ -1,5 +1,5 @@
 name: hasql
-version: 1.4.0.1
+version: 1.4.1
 category: Hasql, Database, PostgreSQL
 synopsis: An efficient PostgreSQL driver with a flexible mapping API
 description:
@@ -67,7 +67,7 @@
     loch-th ==0.2.*,
     mtl >=2 && <3,
     placeholders ==0.1.*,
-    postgresql-binary >=0.12.1 && <0.13,
+    postgresql-binary >=0.12.2 && <0.13,
     postgresql-libpq ==0.9.*,
     profunctors >=5.1 && <6,
     text >=1 && <2,
diff --git a/library/Hasql/Decoders.hs b/library/Hasql/Decoders.hs
--- a/library/Hasql/Decoders.hs
+++ b/library/Hasql/Decoders.hs
@@ -53,6 +53,7 @@
   hstore,
   enum,
   custom,
+  refine,
   -- * Array
   Array,
   dimension,
diff --git a/library/Hasql/Private/Decoders.hs b/library/Hasql/Private/Decoders.hs
--- a/library/Hasql/Private/Decoders.hs
+++ b/library/Hasql/Private/Decoders.hs
@@ -332,6 +332,13 @@
 custom fn = Value (Value.decoderFn fn)
 
 {-|
+Refine a value decoder, lifting the possible error to the session level.
+-}
+{-# INLINABLE refine #-}
+refine :: (a -> Either Text b) -> Value a -> Value b
+refine fn (Value v) = Value (Value.Value (ask >>= \b -> lift (A.refine fn (Value.run v b))))
+
+{-|
 A generic decoder of @HSTORE@ values.
 
 Here's how you can use it to construct a specific value:
diff --git a/library/Hasql/Private/Prelude.hs b/library/Hasql/Private/Prelude.hs
--- a/library/Hasql/Private/Prelude.hs
+++ b/library/Hasql/Private/Prelude.hs
@@ -26,7 +26,7 @@
 import Control.Monad.Trans.Cont as Exports hiding (shift, callCC)
 import Control.Monad.Trans.Except as Exports (ExceptT(ExceptT), Except, except, runExcept, runExceptT, mapExcept, mapExceptT, withExcept, withExceptT, throwE, catchE)
 import Control.Monad.Trans.Maybe as Exports
-import Control.Monad.Trans.Reader as Exports (Reader, runReader, mapReader, withReader, ReaderT(ReaderT), runReaderT, mapReaderT, withReaderT)
+import Control.Monad.Trans.Reader as Exports (Reader, ask, runReader, mapReader, withReader, ReaderT(ReaderT), runReaderT, mapReaderT, withReaderT)
 import Control.Monad.Trans.State.Strict as Exports (State, runState, evalState, execState, mapState, withState, StateT(StateT), runStateT, evalStateT, execStateT, mapStateT, withStateT)
 import Control.Monad.Trans.Writer.Strict as Exports (Writer, runWriter, execWriter, mapWriter, WriterT(..), execWriterT, mapWriterT)
 import Data.Functor.Compose as Exports
