|
9 | 9 | map_types(f, ::Type{NamedTuple{names, types}}) where {names, types} =
|
10 | 10 | NamedTuple{names, map_types(f, types)}
|
11 | 11 |
|
| 12 | +all_types(f, ::Type{Tuple{}}, ::Type{T}) where {T<:Tuple} = true |
| 13 | + |
| 14 | +function all_types(f, ::Type{S}, ::Type{T}) where {S<:Tuple, T<:Tuple} |
| 15 | + f(tuple_type_head(S), tuple_type_head(T)) && all_types(f, tuple_type_tail(S), tuple_type_tail(T)) |
| 16 | +end |
| 17 | + |
| 18 | +all_types(f, ::Type{NamedTuple{n1, t1}}, ::Type{NamedTuple{n2, t2}}) where {n1, t1, n2, t2} = |
| 19 | + all_types(f, t1, t2) |
| 20 | + |
12 | 21 | map_params(f, ::Type{Tuple{}}) = ()
|
13 | 22 | function map_params(f, ::Type{T}) where {T<:Tuple}
|
14 | 23 | (f(tuple_type_head(T)), map_params(f, tuple_type_tail(T))...)
|
@@ -58,3 +67,11 @@ function createtype(::Type{<:Pair}, names, types)
|
58 | 67 | tp = types.parameters
|
59 | 68 | Pair{tp[1], tp[2]}
|
60 | 69 | end
|
| 70 | + |
| 71 | +iseltype(::S, ::T) where {S, T<:AbstractArray} = iscompatible(S, T) |
| 72 | + |
| 73 | +iscompatible(::Type{S}, ::Type{<:AbstractArray{T}}) where {S, T} = S<:T |
| 74 | + |
| 75 | +function iscompatible(::Type{S}, ::Type{StructArray{T, N, C}}) where {S, T, N, C} |
| 76 | + all_types(iscompatible, staticschema(S), C) |
| 77 | +end |
0 commit comments