/Я language (β)/Snippets/Initialising data structures/
Term initialising usually refers to languages with manual memory management, but here it's used in context of definig it standalone.
We need a special natural transformation for it. Let's instantiate categories/functors one step at a time and turn everything infix:
The simplest functor called Alone (aka Identity) has only 1 natural transformation of this kind available:
Unit object represents a slot with a value inside:
Meanwhile Maybe functor has 2 such natural transformations:
Unit represents a slot with a value inside, Void represents an empty box:
Challenge: why such a natural transformation doesn't exist?
There are functors that could be represented by Unit:
Challenge: why such a natural transformation does exist?
Challenge: why such a natural transformation doesn't exist?
But Vector, List and Nonempty List could contain more than 1 item therefore we need more Units:
Challenge: why these natural transformations do not exist?