@@ -145,8 +145,12 @@ tupleToMap (RelationTuple attrs tupVec) = M.fromList assocList
145145 where
146146 assocList = V.toList $ V.map (\(index, attr) -> (attributeName attr, tupVec V.! index)) (V.indexed attrs)
147147
148−verifyTuple :: RelationTuple -> Either RelationalError RelationTuple
149−verifyTuple tuple = V.foldr (\attr acc ->
148+verifyTuple :: Attributes -> RelationTuple -> Either RelationalError RelationTuple
149+verifyTuple attrs tuple = if V.length attrs /= V.length (tupleAtoms tuple) then
150+ Left $ TupleAttributeCountMismatchError 0
151+ else
152+
153+ V.foldr (\attr acc ->
150154 case atomForAttributeName (attributeName attr) tuple of
151155 Left err -> Left err
152156 Right atom -> case atomTypeForAttributeName (attributeName attr) (tupleAttributes tuple) of
@@ -156,6 +160,7 @@ verifyTuple tuple = V.foldr (\attr acc ->
156160 acc
157161 else
158162 Left $ TupleAttributeTypeMismatchError (attributesFromList [attr])
159− ) (Right tuple) (tupleAttributes tuple)
163+ ) (Right tuple) attrs
164+
160165
161166