wiki:FirstPrinciples/Nesting

Nesting

The first eukaryote cell was the result of two prokaryotic cells merging together, such that one cell ended up inside another, which is nesting. Later these inner cells specialized into organelles such as Mitochondria.

Nesting is a fundamental principle. Nested structures, concrete or abstract, is the basis of everything. Numbers could be thought of as nested abstractions.

The only way to establish an order of evaluation in a lazy language is via nesting of function calls, which is an implementation of the causality principle itself, if you think about it for a while. No wonder Monads and other things desugars into nested function calls.


Nesting

Nesting is a fundamental universal notion of What Is.

Nesting is to have something inside the other. Cells inside another cells is nesting. Inner cells has been adapted to be sub-processes (machines) inside a cell. Multicellularity is a higher level of nesting. Systems and subsystems, multiple organs is nesting too.

We got all kinds of animals or plants because they have evolved form a single ancestor and branched out in a sort of abstract tree-like structure. Each new species could be viewed as an outer layer of previous ones, but also as a branch or a leaf.

Nesting is thus related to recursion (recursive processes) which is also real. It is a process which builds up on itself.

Nesting of abstractions is a similar notion. This is how we got categories of things, classes of objects and abstract Sets. It is just nesting.

Wrapping

This is the notion of Lifting into a new context, separated by an abstraction barrier.

The concept of a Functor is used as a generalization of lifting (wrapping). Type-tagging is how it is implemented.

A particular instance of a functor type used at the implementation side.

The lifting is done by type-tagging or wrapping into a new type, which is, again, could be viewed as nesting of types.

All the Kleisli categories, monads, etc, are specialization of wrapping, which is nesting or partitioning if values do not overlap.

Abstraction Barrier

Abstraction barriers separate abstract partitions with abstract stuff in them.

This separation is enforced at the type level, by using higher-order types and is guaranteed by the type-checker.

The types are modeled as a category Hask, with some Kleisli category of Monads "above" it. Some types are being lifted up into that Kleisli category (and never return).

Type-classes

Composition of traits is even better notion than nesting, and a better methodology of modeling (describing) things.

Lets say composition of traits is a partial nesting.

Wrapping and unwrapping at a type level is just nesting and separation/partitioning of concepts. Sets are used as a formal model.

Categories

Categories are viewed as the most general abstract structure, of which types, classes and traits are specializations.

All that category theory stuff is just wrapping and unwrapping.

Last modified 4 months ago Last modified on Sep 25, 2020, 4:57:04 AM
Note: See TracWiki for help on using the wiki.