include "primitives.alh"
include "object_operations.alh"
include "modelling.alh"

Boolean function main(model : Element):
	// Find all source elements and add them to the target element
	// We actually only have to change the type of each element and rename a bit!
	// Model merge operations in the Modelverse take care of the rest automatically

	Element all_elements
	Element split
	String key
	String new_key
	String type

	all_elements = dict_keys(model["model"])

	while (set_len(all_elements) > 0):
		key = set_pop(all_elements)
		type = read_type(model, key)
		split = string_split(type, "/")
		// Got the type, which might contain a /
		if (list_len(split) > 1):
			type = list_read(split, 1)
			// Strip of the part before the / and make it into "DEVS"
			retype(model, key, "result/" + type)

	return True!
