@@ -444,6 +444,14 @@ function coerce_attrvar_component(
444444 return f
445445end
446446
447+ """ Coerce an arbitrary julia function to a LooseVarFunction assuming no variables"""
448+ function coerce_attrvar_component (ob:: Symbol , f:: Function , d:: TypeSet{T} ,cd:: TypeSet{T′} ,
449+ dom_size:: Int , codom_size:: Int ) where {T,T′}
450+ dom_size == 0 || error (" Cannot specify $ob component with $f with $dom_size domain variables" )
451+ coerce_attrvar_component (ob, LooseVarFunction {T,T′} ([], f, FinSet (codom_size)),
452+ d, cd, dom_size,codom_size)
453+ end
454+
447455function Base. getindex (α:: ACSetTransformation , c)
448456 get (α. components, c) do
449457 c ∈ attrtypes (acset_schema (dom (α))) || error (" No object or attribute type with name $c " )
@@ -498,9 +506,16 @@ ACSetTransformation(components, X::DynamicACSet, Y::DynamicACSet) =
498506 acomps = NamedTuple (filter (∈ (attrtypes (S))∘ first, pairs (components)))
499507 length (ocomps) + length (acomps) == length (components) ||
500508 error (" Not all names in $(keys (components)) are objects or attribute types" )
501- is_tight = true
509+ is_tight = true # we do this with a `for` loop (not `all`) because comptime
502510 for a in acomps
503- is_tight &= (a isa Union{VarFunction, Function, AbstractVector} || a. loose isa IdentityFunction)
511+ if a isa Function
512+ is_tight = false
513+ elseif a isa LooseVarFunction && ! (a. loose isa IdentityFunction)
514+ is_tight = false
515+ elseif a isa Union{VarFunction, AbstractVector}
516+ else
517+ error (" Unexpected type for attrtype component of ACSetTransformation" )
518+ end
504519 end
505520 if is_tight
506521 T = is_struct ? StructTightACSetTransformation{S} : DynamicTightACSetTransformation
0 commit comments