Definition of the standard frog.collections library for FROG v0.1
FROG — Free Open Graphical Language
- 1. Overview
- 2. Goals
- 3. Relation with Other Specifications
- 4. Role of
frog.collections - 5. Naming and Namespace
- 6. Scope for v0.1
- 7. Collection Model for v0.1
- 8. Typing Model
- 9. Structural Query Functions
- 10. Element Access and Update Functions
- 11. Array Growth and Combination Functions
- 12. Subarray Functions
- 13. Diagram Representation
- 14. Validation Rules
- 15. Examples
- 16. Out of Scope for v0.1
- 17. Summary
This document defines the standard frog.collections library for FROG v0.1.
The frog.collections library provides a first standardized set of collection-oriented primitives for executable FROG diagrams.
For FROG v0.1, this library is intentionally limited to array-oriented primitives. It standardizes a compact but useful set of operations for:
- array size inspection,
- emptiness checks,
- element access,
- element replacement,
- array growth,
- array concatenation,
- subarray extraction.
This library extends the practical expressiveness of FROG without expanding the minimal mandatory kernel defined by frog.core.
- Practicality — provide a useful first standard collection library for everyday graphical programming.
- Minimality — keep the v0.1 surface small enough to remain durable and easy to implement.
- Clarity — assign every primitive a clear, stable role and a stable port model.
- Portability — ensure collection primitives have portable source-level meaning across conforming implementations.
- Extensibility — leave room for future collection families beyond arrays without forcing them into v0.1.
This document complements the following specifications:
- Expression/Diagram.md — defines how library primitives are serialized as executable diagram nodes.
- Expression/Type.md — defines built-in types, including array types, and the compatibility and coercion rules that apply to primitive ports.
- Expression/Control structures.md — defines standardized language structures, which remain distinct from ordinary primitive functions.
- Libraries/Core.md — defines the minimal built-in primitive kernel on top of which higher-level library families may be added.
This document defines the standardized collection primitive catalog. It does not redefine the graph model, the type system, or the standardized control-structure model.
The frog.collections library provides standardized collection-oriented executable primitives for FROG diagrams.
In language terms, these are library-level primitive functions.
In the serialized diagram representation defined by Expression/Diagram.md, calls to these functions are represented as nodes of kind primitive.
For example:
frog.collections.lengthis a standardized collection primitive,- in a diagram, that function call appears as a
primitivenode withtype = "frog.collections.length".
This library is a standard sibling of frog.core, not an expansion of it.
FROG uses the following general namespace pattern for standardized primitives:
frog.<library>.<primitive>
For this document:
frogidentifies the language namespace,collectionsidentifies the standard collections library,- the final segment identifies the primitive name.
Examples:
frog.collections.length frog.collections.get frog.collections.set frog.collections.append frog.collections.concat frog.collections.slice
Primitive names in frog.collections SHOULD use lowercase snake_case where multiple words are needed.
FROG v0.1 standardizes the following initial collection primitives:
- structural query functions,
- element access and update functions,
- array growth and combination functions,
- subarray extraction.
In v0.1, these functions apply only to standardized FROG array types.
This document does not yet standardize:
- maps,
- sets,
- dictionaries,
- heterogeneous tuples or records,
- higher-order collection functions such as
map,filter, orreduce, - sorting, searching, or advanced reshaping catalogs.
For FROG v0.1, the only standardized collection family is the built-in array family defined by Expression/Type.md.
Accordingly:
array<T>is a valid collection type with dynamic size,array<T, N>is a valid collection type with fixed size,- nested arrays are valid when the element type is itself an array type.
All collection primitives in this document operate on homogeneous arrays.
When a primitive in this document returns an array whose size depends on runtime values rather than a compile-time fixed type expression, the output type is the dynamic array form array<T>.
All frog.collections primitives are typed according to Expression/Type.md.
Unless stated otherwise:
- array inputs MUST have valid FROG array types,
- element ports MUST be type-compatible with the array element type,
- index and length ports in this document MUST use type
u64, - all implicit coercions MUST follow the standard FROG coercion rules,
- all functions in this document are stateless and side-effect-free.
For primitives that require an index to be in range, the index validity condition is part of the primitive contract. If an implementation can prove a violation statically, it MUST reject the graph as invalid. If the violation is only detectable at execution time, the active execution profile MUST define the corresponding runtime failure behavior.
Returns the number of elements in an array.
- input port:
array - output port:
length
Rules:
- the input MUST have type
array<T>orarray<T, N>, - the output type is
u64.
For a fixed-size input array, the returned value is the fixed declared size. For a dynamic array, the returned value is the runtime element count.
Returns whether an array contains zero elements.
- input port:
array - output port:
result
Rules:
- the input MUST have type
array<T>orarray<T, N>, - the output type is
bool.
Returns the element stored at a given index.
- input ports:
array,index - output port:
value
Rules:
arrayMUST have typearray<T>orarray<T, N>,indexMUST have typeu64,valuehas typeT,- the index MUST satisfy
index < length(array).
Returns an array equal to the input array except at one index, where the value is replaced.
- input ports:
array,index,value - output port:
result
Rules:
arrayMUST have typearray<T>orarray<T, N>,indexMUST have typeu64,valueMUST be type-compatible withT,- the index MUST satisfy
index < length(array).
Output typing:
- if the input type is
array<T>, the output type isarray<T>, - if the input type is
array<T, N>, the output type isarray<T, N>.
Returns an array formed by appending one element to the end of the input array.
- input ports:
array,value - output port:
result
Rules:
arrayMUST have typearray<T>orarray<T, N>,valueMUST be type-compatible withT.
Output typing:
- the output type is
array<T>.
This output is dynamic in v0.1 even if the input array has fixed size, because the result length differs from the input length.
Returns an array formed by concatenating two arrays of compatible element type.
- input ports:
a,b - output port:
result
Rules:
aMUST have typearray<T1>orarray<T1, N1>,bMUST have typearray<T2>orarray<T2, N2>,T1andT2MUST be identical or implicitly coercible to a common element typeT.
Output typing:
- the output type is
array<T>.
Returns a contiguous subarray starting at a given index and spanning a given number of elements.
- input ports:
array,start,length - output port:
result
Rules:
arrayMUST have typearray<T>orarray<T, N>,startMUST have typeu64,lengthMUST have typeu64,- the requested slice MUST satisfy
start + length <= length(array).
Output typing:
- the output type is
array<T>.
The result type is dynamic in v0.1 because the slice length is provided as a runtime value.
Calls to frog.collections primitives are serialized as primitive nodes in the diagram.
Example:
{
"id": "len_1",
"kind": "primitive",
"type": "frog.collections.length"
}Another example:
{
"id": "get_1",
"kind": "primitive",
"type": "frog.collections.get"
}The exact port existence, direction, and typing of these nodes are resolved from this specification together with the type system and the graph rules.
Implementations MUST enforce the following rules:
- every
frog.collectionsprimitive reference MUST identify a valid standardized primitive name defined in this document, - all required input ports for the referenced primitive MUST exist,
- all produced output ports MUST match the primitive definition,
- all array inputs MUST use valid FROG array types,
- all implicit coercions MUST follow Expression/Type.md.
For frog.collections.get and frog.collections.set specifically:
- the
indexinput MUST have typeu64, - the referenced element position MUST be in range.
For frog.collections.slice specifically:
startandlengthMUST both have typeu64,- the requested slice interval MUST be valid for the input array.
For frog.collections.append, frog.collections.concat, and frog.collections.set:
- value inputs MUST be type-compatible with the resolved array element type.
{
"id": "len_1",
"kind": "primitive",
"type": "frog.collections.length"
}Conceptual ports:
array → length
{
"id": "get_1",
"kind": "primitive",
"type": "frog.collections.get"
}Conceptual ports:
array, index → value
{
"id": "set_1",
"kind": "primitive",
"type": "frog.collections.set"
}Conceptual ports:
array, index, value → result
{
"id": "append_1",
"kind": "primitive",
"type": "frog.collections.append"
}Conceptual ports:
array, value → result
{
"id": "slice_1",
"kind": "primitive",
"type": "frog.collections.slice"
}Conceptual ports:
array, start, length → result
{
"diagram": {
"nodes": [
{ "id": "input_a", "kind": "interface_input", "interface_port": "a" },
{ "id": "input_b", "kind": "interface_input", "interface_port": "b" },
{ "id": "concat_1", "kind": "primitive", "type": "frog.collections.concat" },
{ "id": "output_result", "kind": "interface_output", "interface_port": "result" }
],
"edges": [
{ "id": "e1", "from": { "node": "input_a", "port": "value" }, "to": { "node": "concat_1", "port": "a" } },
{ "id": "e2", "from": { "node": "input_b", "port": "value" }, "to": { "node": "concat_1", "port": "b" } },
{ "id": "e3", "from": { "node": "concat_1", "port": "result" }, "to": { "node": "output_result", "port": "value" } }
]
}
}
The following are outside the strict scope of frog.collections in v0.1:
- maps, sets, dictionaries, and key-value collection families,
- heterogeneous tuple, record, or cluster collection primitives,
- sorting and searching catalogs,
- insert-at and remove-at catalogs,
- reshape, transpose, or multidimensional array algebra catalogs beyond what is expressible through ordinary nested arrays,
- higher-order collection primitives such as
map,filter,reduce, orfold, - streaming and lazy collection models,
- text-oriented collection semantics, which belong in a dedicated text library.
The frog.collections library defines the first standardized collection-oriented primitive set for FROG v0.1.
It provides:
- array size inspection,
- emptiness checks,
- element access,
- element replacement,
- array append,
- array concatenation,
- subarray extraction.
This library is intentionally compact. Its purpose is to provide a durable and practical first collection vocabulary aligned with the current FROG v0.1 type system while leaving room for richer collection families in later revisions.
End of FROG Collections Library Specification