mirror of
https://github.com/nikita-volkov/hasql.git
synced 2024-12-27 20:44:30 +03:00
Add MonadFail instance for Row
This commit is contained in:
parent
46b836796e
commit
2c9c2377e1
@ -113,7 +113,7 @@ x = (,,) '<$>' ('column' . 'nullable') 'int8' '<*>' ('column' . 'nonNullable') '
|
|||||||
@
|
@
|
||||||
-}
|
-}
|
||||||
newtype Row a = Row (Row.Row a)
|
newtype Row a = Row (Row.Row a)
|
||||||
deriving (Functor, Applicative, Monad)
|
deriving (Functor, Applicative, Monad, MonadFail)
|
||||||
|
|
||||||
{-|
|
{-|
|
||||||
Lift an individual non-nullable value decoder to a composable row decoder.
|
Lift an individual non-nullable value decoder to a composable row decoder.
|
||||||
|
@ -3,14 +3,19 @@ module Hasql.Private.Decoders.Row where
|
|||||||
import Hasql.Private.Prelude hiding (error)
|
import Hasql.Private.Prelude hiding (error)
|
||||||
import Hasql.Private.Errors
|
import Hasql.Private.Errors
|
||||||
import qualified Database.PostgreSQL.LibPQ as LibPQ
|
import qualified Database.PostgreSQL.LibPQ as LibPQ
|
||||||
|
import qualified Data.Text as T
|
||||||
import qualified PostgreSQL.Binary.Decoding as A
|
import qualified PostgreSQL.Binary.Decoding as A
|
||||||
import qualified Hasql.Private.Decoders.Value as Value
|
import qualified Hasql.Private.Decoders.Value as Value
|
||||||
|
import Control.Monad.Fail (MonadFail(..))
|
||||||
|
|
||||||
|
|
||||||
newtype Row a =
|
newtype Row a =
|
||||||
Row (ReaderT Env (ExceptT RowError IO) a)
|
Row (ReaderT Env (ExceptT RowError IO) a)
|
||||||
deriving (Functor, Applicative, Monad)
|
deriving (Functor, Applicative, Monad)
|
||||||
|
|
||||||
|
instance MonadFail Row where
|
||||||
|
fail = error . ValueError . T.pack
|
||||||
|
|
||||||
data Env =
|
data Env =
|
||||||
Env !LibPQ.Result !LibPQ.Row !LibPQ.Column !Bool !(IORef LibPQ.Column)
|
Env !LibPQ.Result !LibPQ.Row !LibPQ.Column !Bool !(IORef LibPQ.Column)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user