Skip to content

Commit b78097a

Browse files
committed
feat: add children to required interface
1 parent 59c0878 commit b78097a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/Interfaces.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ function _check_create_node(tree::AbstractExpressionNode)
226226
NT = with_type_parameters(N, Float16)
227227
return NT() isa NT
228228
end
229+
function _check_children(tree::AbstractExpressionNode{T,D}) where {T,D}
230+
tree.degree == 0 && return true
231+
return children(tree) isa Tuple{typeof(tree),Vararg{typeof(tree)}} &&
232+
children(tree, Val(D)) isa Tuple &&
233+
length(children(tree, Val(D))) == D &&
234+
length(children(tree, Val(1))) == 1
235+
end
229236
function _check_copy(tree::AbstractExpressionNode)
230237
return copy(tree) isa typeof(tree)
231238
end
@@ -360,6 +367,7 @@ end
360367
ni_components = (
361368
mandatory = (
362369
create_node = "creates a new instance of the node type" => _check_create_node,
370+
children = "returns the children of the node" => _check_children,
363371
copy = "returns a copy of the tree" => _check_copy,
364372
hash = "returns the hash of the tree" => _check_hash,
365373
any = "checks if any element of the tree satisfies a condition" => _check_any,

0 commit comments

Comments
 (0)