Principles
Molecular biology, however, is all about particular “concrete structures”. It does not operate on abstract entities.
Mother Nature does not count. It has no abstract notion of a Number. (I does not have any abstract notions whatsoever). It does structural pattern matching and structural information encoding.
Mother Nature, that part of it which we call Molecular Biology, uses explict structural markers which we could call tags. Tagging (or marking with a distinct pattern) is a universal concept. It has been discovered by the process of evolution.
For us, like for the holy LISP and ML old-timers, typing is implicit type-tagging. and (a set of) data-constructors are considered as tags.
Topology (sort of)
There is an old principle, which comes from algorithm charting techniques (in the great times they chart the control flow).
Topologically, so to speak, all we need is sequences, branches (forks) and loops (or rather recursive spirals).
Loops are, basically, jumping back to the conditional expression (a test) which branches the control, avoidng arbitrary gotos.
So, imperative loops have explicit branching in them. A loop yields a circular process, which keeps its state in variables.
Recursive procedures branch on the required test for a base-case.
A recursive process is a spiral-shaped one, which unfolds by passing its reduced state along to each new recursive function call.
Its termination is guaranteeed by the base case and reduced coils of a spieral, whcih converge at the base case.
Recursion could be double (a function called itself twice) or mutual (two functions call each other), resulting in different “topologies”.
Notice that as a binary teee is just a list with two tails per node, a dobule recursion, like in quicksort
, produces a tree-shaped process.
This is a big finding. The meaning is that every computable program is reducible to just these 3 “shapes” or “topologies” of a control flow.
Sets
Mathematically, both a sum-type and a product-type is a set of possible values. Here a set is a prtition. The difference is in their algebraic structure or topological shape of the type. Yes, types are sets of values plus some algebraic structure and also nested structure of values.
Sum-types
a finite set of tags for values of the type.
- multiple constructors.
- multiple distinct patterns to match.
a sum-type has \(n\) constructors and corresponding \(n\) distinct patterns (selectors), wehere \(n >= 2\)
Product types
a single implicit tag for all values of the type
- a single implicit or explicit constructor
- a single nested pattern
In other languages each particular structure is of its own type with an implicit tag.
a product-type has single constructor and a single pattern (selector) on which netsted patterns can be matched
Product types have values with its own particular structure. The set of all possible values corresponds to a Cartesian Product of Sets of its components.
any-of
either-of
A Set of all possible outcomes (any-of) \(\{ True, False \}\) A either-of Type
True | False
and-also
Abstract: A
and-also B
, A && B
(without any representation)
A a pair: explicit ordering, position based selection
f :: a -> b -> (a, b) f = \a -> \b -> (a, b)
Pattern-matching on a particular structure
f :: (a, b) -> a f = \(a, _) -> a
f :: (a, b) -> b f = \(_. b) -> b
A shape of a type
A product-type, any-of-type, and-also-type
a tuple
( _ , _ )
a record
{ _ , _ }
A sum-type, either-of-type
a variant
_ | _
records
data AB = AB {a :: Int, b :: Int} f = \ab -> ab.a f = \ab -> ab.b
tuples usually implemented and records with fields 1,2,3…