UP | HOME

Principle Guided Development

High-level

Stay at the highest possible level of a language.

Layered (hierarchical) DSLs to rise the level of abstraction to actual concepts from the problem domain.

All you need is Lambda

The Lambda Calculus showed us that abstraction and application is enough for everything (but too unrestricted - everything could be applied to everything else, which is wrong).

Just 3 shapes.

Every algorithm could be expressed as a flow-chart with just 3 forms

  • sequencing
  • branching (conditionals, pattern-matching)
  • looping (which must be is a recursive call really)

Just sums, products and functions

Algebraic data types correspond to so-called abstract universal constrictions

  • a product
  • a coproduct (or a sum)
  • an arrow (a single step or transition)

Nesting

Once you have these universal basic building blocks you nest them.

This is how one gets arbitrary complex, but fully specified and well-typed abstract structures.

Composition

The essence of a Monoid is not an identity element, but the closure property - that the result of the associative binary operation is in the same set (of the same type or kind).

It is due to this property everything composes in principle.

Associativity is also crucial, and an identity is required to do it “right” (the base cases).

Immutability & Persistence

Immutable and therefore persistent data does not require locks or any synchronization primitives.

This eliminates the whole classes of subtle bugs at the cost of sub-optimal space requirements and performance.

Abstraction barriers

Abstract interfaces (of ADTs) act as cell membranes.

With them on just puts everything together, like Lego blocks.

Pattern-matching

The notion for a nested value of being of exactly the same shape.

Suddenly one has a precise language to talk about shapes of values.

Curried functions

Uniformity is a sign of approaching perfection. Partial application is essential.

Parameterized types

Type-constructors are just the same notion as data-constructors, but at the type-level.

Type-classes of Haskell

This is how one uniformly specifies abstract interfaces at the type-level.

To be an X (to be taken as an X) is to implement this and that.

Modules of Ocaml

They just have done it right, in the sense of what the Buddha meant by “just right” - nothing to remove, nothing to add.

Currying at the type level

Partial application of type-constructors is useful.

We still don’t have this in Haskell or Ocaml. Scala 3 is going in this direction.

Author: <schiptsov@gmail.com>

Email: lngnmn2@yahoo.com

Created: 2023-08-08 Tue 18:39

Emacs 29.1.50 (Org mode 9.7-pre)