@@ -81,7 +81,7 @@ resolveDataConstructorTypeVars dCons@(DataConstructorDef _ defArgs) aTypeArgs tC
81 --if any two maps have the same key and different values, this indicates a type arg mismatch
81 --if any two maps have the same key and different values, this indicates a type arg mismatch
82 let typeVarMapFolder valMap acc = case acc of
82 let typeVarMapFolder valMap acc = case acc of
83 Left err -> Left err
83 Left err -> Left err
84− Right accMap -> do
84+ Right accMap ->
85 case resolveAtomTypesInTypeVarMap valMap accMap of
85 case resolveAtomTypesInTypeVarMap valMap accMap of
86 Left (TypeConstructorTypeVarMissing _) -> Left (DataConstructorTypeVarsMismatch (DCD.name dCons) accMap valMap)
86 Left (TypeConstructorTypeVarMissing _) -> Left (DataConstructorTypeVarsMismatch (DCD.name dCons) accMap valMap)
87 Left err -> Left err
87 Left err -> Left err
@@ -254,6 +254,9 @@ resolveTypeInAtom typeFromRelation@(ConstructedAtomType _ tvMap) atomIn@(Constru
254 atomArgTypes <- resolvedAtomTypesForDataConstructorDefArgs tConss tvMap dConsDef
254 atomArgTypes <- resolvedAtomTypesForDataConstructorDefArgs tConss tvMap dConsDef
255 newArgs <- mapM (\(atom, atomTyp) -> resolveTypeInAtom atomTyp atom tConss) (zip args atomArgTypes)
255 newArgs <- mapM (\(atom, atomTyp) -> resolveTypeInAtom atomTyp atom tConss) (zip args atomArgTypes)
256 pure (ConstructedAtom dConsName newType newArgs)
256 pure (ConstructedAtom dConsName newType newArgs)
257+resolveTypeInAtom (RelationAtomType attrs) (RelationAtom (Relation _ tupSet)) tConss = do
258+ let newTups = mapM (resolveTypesInTuple attrs tConss) (asList tupSet)
259+ RelationAtom . Relation attrs . RelationTupleSet <$> newTups
257resolveTypeInAtom _ atom _ = Right atom
260resolveTypeInAtom _ atom _ = Right atom
259-- | When creating a tuple, the data constructor may not complete the type constructor arguments, so the wildcard "TypeVar x" fills in the type constructor's argument. The tuple type must be resolved before it can be part of a relation, however.
262-- | When creating a tuple, the data constructor may not complete the type constructor arguments, so the wildcard "TypeVar x" fills in the type constructor's argument. The tuple type must be resolved before it can be part of a relation, however.
@@ -286,17 +289,17 @@ validateAtomType _ _ = pure ()
287--ensure that all type vars are fully resolved
290--ensure that all type vars are fully resolved
288validateTypeVarMap :: TypeVarMap -> TypeConstructorMapping -> Either RelationalError ()
291validateTypeVarMap :: TypeVarMap -> TypeConstructorMapping -> Either RelationalError ()
289−validateTypeVarMap tvMap tConss = mapM_ ((flip validateAtomType) tConss) $ (M.elems tvMap)
292+validateTypeVarMap tvMap tConss = mapM_ (`validateAtomType` tConss) $ M.elems tvMap
291validateTuple :: RelationTuple -> TypeConstructorMapping -> Either RelationalError ()
294validateTuple :: RelationTuple -> TypeConstructorMapping -> Either RelationalError ()
292−validateTuple (RelationTuple _ atoms) tConss = mapM_ (\a -> validateAtom a tConss) atoms
295+validateTuple (RelationTuple _ atoms) tConss = mapM_ (`validateAtom` tConss) atoms
294--ensure that all types are fully resolved
297--ensure that all types are fully resolved
295validateAtom :: Atom -> TypeConstructorMapping -> Either RelationalError ()
298validateAtom :: Atom -> TypeConstructorMapping -> Either RelationalError ()
296−validateAtom (RelationAtom (Relation _ tupSet)) tConss = mapM_ ((flip validateTuple) tConss) (asList tupSet)
299+validateAtom (RelationAtom (Relation _ tupSet)) tConss = mapM_ (`validateTuple` tConss) (asList tupSet)
297validateAtom (ConstructedAtom _ dConsType atomArgs) tConss = do
300validateAtom (ConstructedAtom _ dConsType atomArgs) tConss = do
298 validateAtomType dConsType tConss
301 validateAtomType dConsType tConss
299− mapM_ ((flip validateAtom) tConss) atomArgs
302+ mapM_ (`validateAtom` tConss) atomArgs
300validateAtom _ _ = pure ()
303validateAtom _ _ = pure ()