-- | Takes a point (position current), a source (guts current),
  -- and a destination (board), and 
combineAt :: Point -> Grid -> Grid -> Grid
combineAt (x,y) src dest = computeVectorS $ traverse dest id insertCell
  where
    (R.Z :. w :. h) = extent src
    insertCell lookupDest spot@(R.Z :. destX :. destY) =
      if any id [ destX < x
                , destX >= x + w
                , destY < y
                , destY >= y + h
                ]
      then lookupDest spot -- No changes here, keep moving...
      else case src ! (R.Z :. destX -x :. destY - y) of
        Nothing -> lookupDest spot -- Nothing new, keep moving...
        occupiedCell -> occupiedCell -- There's something to add, so use that!


-- | Checks if there are any full rows on the board and removes them
combineAt :: Point -> Grid -> Grid -> Grid
combineAt (x,y) src dest = computeVectorS $ traverse dest id insertCell
  where
    (R.Z :. w :. h) = extent src
    insertCell lookupDest spot@(R.Z :. destX :. destY) =
      if any id [ destX < x
                , destX >= x + w
                , destY < y
                , destY >= y + h
                ]
      then lookupDest spot -- No changes here, keep moving...
      else case src ! (R.Z :. destX -x :. destY - y) of
        Nothing -> lookupDest spot -- Nothing new, keep moving...
        occupiedCell -> occupiedCell -- There's something to add, so use that!


-- | Checks if there are any full rows on the board and removes them
combineAt (x,y) src dest = computeVectorS $ traverse dest id insertCell
  where
    (R.Z :. w :. h) = extent src
    insertCell lookupDest spot@(R.Z :. destX :. destY) =
      if any id [ destX < x
                , destX >= x + w
                , destY < y
                , destY >= y + h
                ]
      then lookupDest spot -- No changes here, keep moving...
      else case src ! (R.Z :. destX -x :. destY - y) of
        Nothing -> lookupDest spot -- Nothing new, keep moving...
        occupiedCell -> occupiedCell -- There's something to add, so use that!


-- | Checks if there are any full rows on the board and removes them