Fork me on GitHub

Isn't it somewhat dangerous to think about types as business rules? Static types have real impact on implementation detail in code design. Ideally business rules should be connected only to the API specifications of your system, not the implementation details inside it.


Fascinating question. Coming from an information systems background a “domain” is a constraint / subset on the “universe of discourse”. In fact some SQL implementations actually support DOMAIN as a keyword, though unlike the broad user defined type mechanism it was originally designed to be ie, add an IMAGE type, has devolved to mostly be a constrained range on a base type eg. CustomerId being a positive integer. So Rich Hickey’s “just use maps” and the related slide says they are just functions between key and value. Semantics are on the attribute specifically and not the aggregate. How does one reference the attribute? How does one relate the attribute to others? (cf. attribute modeling) Do we have aggregates of dissimilar attributes, collections of those or links between collections? (Embodied by special case attributes that reference others) Is an equi-join between relations a specialised business rule?


Erratum: "attribute modeling" I meant "anchor modeling".


A type could be seen as a range constraint and applicable set of behaviours on a single representable value. A referenced value of a type could be seen as a fact (with some valid time) about the world. But how does one raise it to being “data” without a version independent reference? A symbolic name or navigation path?


Without identification the value is … what?


So the value has meaning beyond a CPU cycle iff it can stored and retrieved and acted on.


And it needs to be known or verified to be valid.


Which means that it is constrained. There are bitpatterns that are a valid encodings about facts capturing a perception of reality. There seems to a spectrum of talking about where those constraints are applied. Datum = A value Information = Data with meaning encoded in static structure Knowledge = Information which can generate new information by induction


Constraints can be by extension - the allowable values are {x, y…} or by intension the allowable values are “a single digit that can only be succeeded by the next in the sequence from the decimal expansion of pi”.


Typically these constraints are either enacted or tested by behaviour - computation - logic operations such as comparison and branching etc. Whether by microcode on the CPU instruction, the compiler or an interpreter something is comparing the bits to determine if the fact is accurate and to use the pattern to make other choices about what to do next (to act on the facts).


To harness the value of computation we abstract up from the instructions on the bits, to the classic base word types (integer, float), base sequence types (strings, arbitrary precision numbers), to memory structures to tables etc etc


Where and how the constraints are implemented is a spectrum. Is it a type enacted by the CPU operation, the compiler? Is it a user defined type in the code?


In this channel we might agree that some facts are so useful that their valid time is sufficient that there may be multiple applications that can consume and act on them. They are shared facts across sessions, applications and even distributed systems. Capturing the value adding constraints on these facts can be an interesting task (especially over time and eventual consistency).


And we need to communicate that value add of capturing that data through time to other people and systems. Embody the current understanding of the meaning of the facts in many ways both between technical systems and other humans (schema diagrams, code and its documentation etc). “Business rules” are terms that is typically used to try and capture constraints on validity OR identify behaviours that will modify the system to the next valid state. In general they are at the interface between fact populations, cardinalities and time. (Invoice will be status:”overdue” if fully unpaid after ?30? days of being generated). But it is encoded in the name the lack of universality - is generally only one or a few businesses that uses these same rules (though the may be parameterised). They generally aren't domain rules, they are choices made by a small groups of organisations about the population and relationships between facts.


If anyone is interested there is a technique that I have found valuable over the years called Object Role Modelling which is based on a Conceptual Schema Design Protocol. A way of moving from natural language analysis to facts, constraints and business rules (and relational models).;crid=1S59803DSH71Z&amp;sprefix=terry+halpin%2Caps%2C271&amp;ref=nb_sb_ss_ts-doa-p_1_12 Wow - what a ramble. And damn, clojurians has history now. Whoops. Thanks for coming to my TED talk insomniac ramble. Takeaways - values having identity and state over time (but behaviour and validity is where computation comes in). Collections of key -> value functions (maps) is one layer but aggregations to entities and their relationships is valuable when modelling perceptions of reality. Schemata can describe expectations of common structure on populations of entities. (Allows for declarative iteration) Types can encode expectations of structure and behaviour on entities. Where In the spectrum to embody computation best depends upon expected complexities and change rates of entity values, entity cardinalities, structural and behavioural rules.


Hey 🙂 ORM is very interesting to me! Have you translated/applied it into Clojure or a Clojure database before?


And me too! Unfortunately no, I haven't yet been able to apply ORM to say a datomic, xtdb or asana datastore. (Day job is Rails and PostgreSQL). Have been curious how they map for a while now so would love to follow anyone working on an example. Looks like Dr Halpin has also moved closer to Datalog with LogicQL which I haven't read up on yet either.

👍 1

Ooo, I don't think I realised there was a whole book on LogiQL. It looks like there's a complete online version here: (there's the rest of my weekend sorted...) Incidentally, XT's query engine is able to do some similarly fancy things, like the other day I was looking at where it says "Flix supports Datalog constraints enriched with lattice semantics" and had to stop to double-check we could handle the same problem okay: (good news!)

👏 1

Cheers, all - thanks for asking the stimulating questions.