Higher Order Function¶
Core Idea¶
Treating a rule itself as an object that other rules can consume or produce. The first-order layer transforms values; the higher-order layer transforms the transformers — taking a function as argument or returning one as result. The defining move is reification: lifting a rule into the value domain of another rule.
How would you explain it like I'm…
Machine That Makes Machines
Rules About Rules
Functions as First-Class Values
Broad Use¶
- Mathematics: operators on functions — differentiation, the Fourier transform, functionals.
- Programming:
map,filter,reduce, decorators, middleware, currying, and monads. - Law: a meta-rule such as a constitutional amendment procedure — a rule for changing rules.
- Macroeconomic policy: a policy rule like the Taylor rule specifying how the bank sets its rate-setting rule.
- Organizational design: a meta-policy about how policies are written and rescinded; standards for standards.
- Pedagogy: a meta-strategy that takes a teaching plan and returns a spaced-retrieval version of it.
- Machine learning: meta-learning and hyperparameter optimization that take learning algorithms as input.
Clarity¶
Makes visible which axes of variation a system has parameterised over and which it has hard-coded — distinguishing a statute from a constitutional rule, business logic from extension points, a decision from a decision procedure.
Manages Complexity¶
Replaces N specialised mechanisms with one mechanism parameterised over N rules, factoring out combinatorial replication and concentrating change at a single point.
Abstract Reasoning¶
Opens two moves once rules are first-class: a composition algebra over rules (compose, identity, inverse, distribute) and schema-driven generation (reason about a schema's invariants to reason about a whole family of rules at once).
Knowledge Transfer¶
- Programming → law:
optimizer = Adam(beta1=0.9)reads as an amendment procedure — a rule producing rate-of-update rules. - Law → ML: an amendment article reads as a function returning a new constitution.
- Everywhere: the intervention moves — reify, parameterise, compose, constrain — are the same at every level.
Example¶
In calculus the derivative operator D takes a function and returns its derivative, composes with itself (D²), has an approximate inverse (integration), and obeys linearity — mathematics reifying rules-as-objects long before programming.
Relationships to Other Primes¶
Parents (1) — more general patterns this builds on
- Higher Order Function is a kind of Function (Mapping) — The file: 'Not function_mapping — a function-mapping is the FIRST-ORDER layer (data to data); a higher-order function operates on the NEXT layer up, taking or returning functions themselves ... a STRATIFIED EXTENSION of function_mapping.' A specialization where inputs/outputs are themselves mappings.
Path to root: Higher Order Function → Function (Mapping)
Not to Be Confused With¶
- Higher Order Function is not Function Mapping because a function-mapping is the first-order layer (data to data) whereas a higher-order function operates one level up, taking or returning functions themselves.
- Higher Order Function is not Abstraction in general because abstraction omits detail along any axis whereas a higher-order function is the specific abstraction over a rule, reifying it into a passable value.
- Higher Order Function is not Indirection because indirection interposes a level of reference (which target is reached) whereas a higher-order function interposes a level of behavioural parameterisation (which operation is applied).