@@ -209,19 +209,20 @@ resolveTypesInTuple resolvedAttrs (RelationTuple _ tupAtoms) = do
209209 Right (RelationTuple resolvedAttrs (V.fromList newAtoms))
210210
211211-- | Validate that the type is provided with complete type variables for type constructors.
212−validateAtomType :: AtomType -> TypeConstructorMapping -> Maybe RelationalError
212+validateAtomType :: AtomType -> TypeConstructorMapping -> Either RelationalError ()
213213validateAtomType typ@(ConstructedAtomType tConsName tVarMap) tConss = do
214− (tConsDef, _) <- findTypeConstructor tConsName tConss
215− case tConsDef of
216− ADTypeConstructorDef _ tVarNames -> let expectedTyVarNames = S.fromList tVarNames
217− actualTyVarNames = M.keysSet tVarMap
218− diff = S.difference expectedTyVarNames actualTyVarNames in
219− if not (S.null diff) then
220− Just $ TypeConstructorTypeVarsMismatch expectedTyVarNames actualTyVarNames
221− else
222− Nothing
223− _ -> Just (TypeConstructorAtomTypeMismatch tConsName typ)
224−validateAtomType _ _ = Nothing
214+ case findTypeConstructor tConsName tConss of
215+ Nothing -> Left (TypeConstructorAtomTypeMismatch tConsName typ)
216+ Just (tConsDef, _) -> case tConsDef of
217+ ADTypeConstructorDef _ tVarNames -> let expectedTyVarNames = S.fromList tVarNames
218+ actualTyVarNames = M.keysSet tVarMap
219+ diff = S.difference expectedTyVarNames actualTyVarNames in
220+ if not (S.null diff) then
221+ Left $ TypeConstructorTypeVarsMismatch expectedTyVarNames actualTyVarNames
222+ else
223+ Right ()
224+ _ -> Right ()
225+validateAtomType _ _ = Right ()
225226
226−validateTuple :: RelationTuple -> TypeConstructorMapping -> Maybe RelationalError
227−validateTuple (RelationTuple _ atoms) tConss = mapM_ (\a -> validateAtomType (atomTypeForAtom a) tConss) atoms >>= pure Nothing
227+validateTuple :: RelationTuple -> TypeConstructorMapping -> Either RelationalError ()
228+validateTuple (RelationTuple _ atoms) tConss = mapM_ (\a -> validateAtomType (atomTypeForAtom a) tConss) atoms