Do functions with type variables get duplicated like C++ template functions? Is there run-time overhead for using type variables?
No and no. Each Cyclone function gives rise to one function in the output, and types are not present at run-time. When a function is called, it does not need to know the types with which the caller is instantiating the type variables, so no instantiation actually occurs—the types are not present at run-time. We do not have to duplicate the code because we either know the size of the type or the size does not matter. This is why we don’t allow type variables of memory kind as parameters—doing so would require code duplication or run-time types.