readEmptyArrayOfRank :: Int -> BS.ByteString -> Maybe (Value, BS.ByteString)
readEmptyArrayOfRank r t
  | Just t' <- symbol '[' t,
    Just t'' <- symbol ']' t' = readEmptyArrayOfRank (r+1) t''
  | otherwise = do
      (pt, t') <- readPrimType t
      v <- case pt of
             "i8" -> Just $ Int8Value (UVec.replicate r 0) UVec.empty
             "i16" -> Just $ Int16Value (UVec.replicate r 0) UVec.empty
             "i32" -> Just $ Int32Value (UVec.replicate r 0) UVec.empty
             "i64" -> Just $ Int64Value (UVec.replicate r 0) UVec.empty
             "u8" -> Just $ Word8Value (UVec.replicate r 0) UVec.empty
             "u16" -> Just $ Word16Value (UVec.replicate r 0) UVec.empty
             "u32" -> Just $ Word32Value (UVec.replicate r 0) UVec.empty
             "u64" -> Just $ Word64Value (UVec.replicate r 0) UVec.empty
             "f32" -> Just $ Float32Value (UVec.replicate r 0) UVec.empty
             "f64" -> Just $ Float64Value (UVec.replicate r 0) UVec.empty
             "bool" -> Just $ BoolValue (UVec.replicate r 0) UVec.empty
             _  -> Nothing
      return (v, t')
readEmptyArrayOfRank :: Int -> BS.ByteString -> Maybe (Value, BS.ByteString)
readEmptyArrayOfRank r t
  | Just t' <- symbol '[' t,
    Just t'' <- symbol ']' t' = readEmptyArrayOfRank (r+1) t''
  | otherwise = do
      (pt, t') <- readPrimType t
      v <- case pt of
             "i8" -> Just $ Int8Value (UVec.replicate r 0) UVec.empty
             "i16" -> Just $ Int16Value (UVec.replicate r 0) UVec.empty
             "i32" -> Just $ Int32Value (UVec.replicate r 0) UVec.empty
             "i64" -> Just $ Int64Value (UVec.replicate r 0) UVec.empty
             "u8" -> Just $ Word8Value (UVec.replicate r 0) UVec.empty
             "u16" -> Just $ Word16Value (UVec.replicate r 0) UVec.empty
             "u32" -> Just $ Word32Value (UVec.replicate r 0) UVec.empty
             "u64" -> Just $ Word64Value (UVec.replicate r 0) UVec.empty
             "f32" -> Just $ Float32Value (UVec.replicate r 0) UVec.empty
             "f64" -> Just $ Float64Value (UVec.replicate r 0) UVec.empty
             "bool" -> Just $ BoolValue (UVec.replicate r 0) UVec.empty
             _  -> Nothing
      return (v, t')
readEmptyArrayOfRank r t
  | Just t' <- symbol '[' t,
    Just t'' <- symbol ']' t' = readEmptyArrayOfRank (r+1) t''
  | otherwise = do
      (pt, t') <- readPrimType t
      v <- case pt of
             "i8" -> Just $ Int8Value (UVec.replicate r 0) UVec.empty
             "i16" -> Just $ Int16Value (UVec.replicate r 0) UVec.empty
             "i32" -> Just $ Int32Value (UVec.replicate r 0) UVec.empty
             "i64" -> Just $ Int64Value (UVec.replicate r 0) UVec.empty
             "u8" -> Just $ Word8Value (UVec.replicate r 0) UVec.empty
             "u16" -> Just $ Word16Value (UVec.replicate r 0) UVec.empty
             "u32" -> Just $ Word32Value (UVec.replicate r 0) UVec.empty
             "u64" -> Just $ Word64Value (UVec.replicate r 0) UVec.empty
             "f32" -> Just $ Float32Value (UVec.replicate r 0) UVec.empty
             "f64" -> Just $ Float64Value (UVec.replicate r 0) UVec.empty
             "bool" -> Just $ BoolValue (UVec.replicate r 0) UVec.empty
             _  -> Nothing
      return (v, t')