--------------------------------------------------------------------------------

-- | Refresh vectors in a shape from the cache.
refreshShape :: VirtualSegmentAlgebra a => Shape V.DVec -> VecBuild a d r (Shape d)
refreshShape shape = T.mapM refreshVec shape
  where
    refreshVec (V.DVec n) = do
        mv <- fromDict n
        case mv of
            Just v -> return $ toDVec v
            Nothing -> $impossible
refreshShape :: VirtualSegmentAlgebra a => Shape V.DVec -> VecBuild a d r (Shape d)
refreshShape shape = T.mapM refreshVec shape
  where
    refreshVec (V.DVec n) = do
        mv <- fromDict n
        case mv of
            Just v -> return $ toDVec v
            Nothing -> $impossible
refreshShape shape = T.mapM refreshVec shape
  where
    refreshVec (V.DVec n) = do
        mv <- fromDict n
        case mv of
            Just v -> return $ toDVec v
            Nothing -> $impossible