Optimize the row parser a bit

This commit is contained in:
Nikita Volkov 2014-10-25 19:39:23 +04:00
parent aed09f367d
commit 47d86b91f2

View File

@ -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) :) $