mirror of
https://github.com/nikita-volkov/hasql.git
synced 2025-01-01 15:04:17 +03:00
Optimize the row parser a bit
This commit is contained in:
parent
aed09f367d
commit
47d86b91f2
@ -13,12 +13,11 @@ instance RowParser b () where
|
|||||||
parseRow row =
|
parseRow row =
|
||||||
if Vector.null row
|
if Vector.null row
|
||||||
then Right ()
|
then Right ()
|
||||||
else Left $ "Row is not empty"
|
else $bug "Not an empty row"
|
||||||
|
|
||||||
instance Backend.Mapping b v => RowParser b (Identity v) where
|
instance Backend.Mapping b v => RowParser b (Identity v) where
|
||||||
parseRow row = do
|
parseRow row = do
|
||||||
h <- maybe (Left $ "Empty row") Right $ Vector.headM row
|
Identity <$> Backend.parseResult (Vector.unsafeHead row)
|
||||||
Identity <$> Backend.parseResult h
|
|
||||||
|
|
||||||
-- Generate tuple instaces using Template Haskell:
|
-- Generate tuple instaces using Template Haskell:
|
||||||
let
|
let
|
||||||
@ -47,9 +46,8 @@ let
|
|||||||
i <- [0 .. pred arity]
|
i <- [0 .. pred arity]
|
||||||
return $ purify $
|
return $ purify $
|
||||||
[|
|
[|
|
||||||
fromMaybe (Left "Invalid row length") $
|
Backend.parseResult $
|
||||||
fmap Backend.parseResult $
|
(Vector.unsafeIndex) $(varE n) $(litE (IntegerL $ fromIntegral i))
|
||||||
(Vector.!?) $(varE n) $(litE (IntegerL $ fromIntegral i))
|
|
||||||
|]
|
|]
|
||||||
queue =
|
queue =
|
||||||
(ConE (tupleDataName arity) :) $
|
(ConE (tupleDataName arity) :) $
|
||||||
|
Loading…
Reference in New Issue
Block a user