readVal :: VSpace -> VGet a -> MDB_val -> IO (a, Int)
readVal vc p v = _vget (vgetFull p) s0 >>= retv where
    size = fromIntegral (mv_size v)
    s0 = VGetS { vget_children = []
               , vget_target = mv_data v
               , vget_limit = mv_data v `plusPtr` size
               , vget_space = vc
               }
    retv (VGetR result _) = return (result, size)
    retv (VGetE eMsg) = fail eMsg

-- vget with initializer for dependencies.
-- asserts that we parse all available input.
readVal :: VSpace -> VGet a -> MDB_val -> IO (a, Int)
readVal vc p v = _vget (vgetFull p) s0 >>= retv where
    size = fromIntegral (mv_size v)
    s0 = VGetS { vget_children = []
               , vget_target = mv_data v
               , vget_limit = mv_data v `plusPtr` size
               , vget_space = vc
               }
    retv (VGetR result _) = return (result, size)
    retv (VGetE eMsg) = fail eMsg

-- vget with initializer for dependencies.
-- asserts that we parse all available input.
readVal vc p v = _vget (vgetFull p) s0 >>= retv where
    size = fromIntegral (mv_size v)
    s0 = VGetS { vget_children = []
               , vget_target = mv_data v
               , vget_limit = mv_data v `plusPtr` size
               , vget_space = vc
               }
    retv (VGetR result _) = return (result, size)
    retv (VGetE eMsg) = fail eMsg

-- vget with initializer for dependencies.
-- asserts that we parse all available input.