/Я language (β)/Snippets/Initialising data structures/

Twitter threadSource code

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:

`ho'nt'yo`³ : target ( t _ a ) ( target ( source ( ( a ) `PLL` o `PRL` ) ( tt o ) )
`ho'nt'yo`³ : Arrow ( t _ a ) ( Arrow ( source ( ( a ) `PLL` o `PRL` ) ( tt o ) )
`ho'nt'yo`³ : Arrow ( t _ a ) ( Arrow ( Arrow ( ( a ) `PLL` o `PRL` ) ( tt o ) )
`ho'nt'yo`³ : Arrow ( Arrow _ a ) ( Arrow ( Arrow ( ( a ) `PLL` o `PRL` ) ( tt o ) )
`ho'nt'yo`³ : _ `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` tt o

The simplest functor called Alone (aka Identity) has only 1 natural transformation of this kind available:

`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Alone o

Unit object represents a slot with a value inside:

> Only `ho'ut'st` A `ho'nt'yo` Spark @ Alone = Alone `ha'nt'ha'st` A

Meanwhile Maybe functor has 2 such natural transformations:

`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Maybe o
`ho'nt'yo`³ : Void `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Maybe o

Unit represents a slot with a value inside, Void represents an empty box:

> Only `ho'ut'st` A `ho'nt'yo` Spark @ Maybe = Exist `ha'nt'ha'st` A
> Null `ho'vt` Unit `ho'nt'yo` Spark @ Maybe = Empty `ha'nt'ha` Unit

Challenge: why such a natural transformation doesn't exist?

`ho'nt'yo`³ : Void `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Alone o

There are functors that could be represented by Unit:

`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Alone o
`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Maybe o
`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` List o
`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Vector 1 o
`ho'nt'yo`³ : Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Nonempty List o

Challenge: why such a natural transformation does exist?

`ho'nt'yo`³ : Void `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` List o

Challenge: why such a natural transformation doesn't exist?

`ho'nt'yo`³ : Void `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Nonempty List o

But Vector, List and Nonempty List could contain more than 1 item therefore we need more Units:

> A `ho'nt'yo` Plain @ List
> A `ho'nt'yo` Plain @ ( Vector 1 )
> A `ho'nt'yo` Plain @ ( Nonempty List )
> A `has` B `ho'nt'yo` Plain @ List
> A `has` B `ho'nt'yo` Plain @ ( Vector 2 )
> A `has` B `ho'nt'yo` Plain @ ( Nonempty List )
> A `has` B `has` C `ho'nt'yo` Plain @ List
> A `has` B `has` C `ho'nt'yo` Plain @ ( Vector 3 )
> A `has` B `has` C `ho'nt'yo` Plain @ ( Nonempty List )

Challenge: why these natural transformations do not exist?

`ho'nt'yo`³ : Unit `S` Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Maybe o
`ho'nt'yo`³ : Unit `S` Unit `AR_` a `AR______` a `AR_` `PLL` o `PRL` `AR___` Vector 1 o