This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mmlang> 5 => int+2-<(nat;nat+10)=(vertex;vertex)=>edge | |
==>edge:('outV'->vertex:('id'->nat:7),'inV'->vertex:('id'->nat:17)) | |
mmlang> int => int+2-<(nat;nat+10)=(vertex;vertex)=>edge | |
==>edge<=int[plus,2] | |
[split,(nat{?}<=int[is,bool<=int[gt,0]];nat{?}<=int[is,bool<=int[gt,0]][plus,10])] | |
[combine,(vertex;vertex)] | |
[as,edge<=(vertex;vertex) | |
[split,('outV'->vertex<=(vertex;vertex)[get,0,_], | |
'inV'->vertex<=(vertex;vertex)[get,1,_])]] |
The [explain]
instruction provides a human readable breakdown of your types (which, if they are not base types, are composed of yet more types).
mmlang> (int;int) => edge => [explain]
==>'
edge<=(int;int)[combine,(vertex<=int[as,nat<=int[is,bool<=int[gt,0]]][as,vertex<=nat[split,('id'->nat)]];vertex<=int[as,nat<=int[is,bool<=int[gt,0]]][as,vertex<=nat[split,('id'->nat)]])<=(int;int)][as,edge<=(vertex<=int[is,bool<=int[gt,0]][split,('id'->nat)];vertex<=int[is,bool<=int[gt,0]][split,('id'->nat)])[split,('outV'->vertex<=(vertex:('id'->nat);vertex:('id'->nat))[get,0,_],'inV'->vertex<=(vertex:('id'->nat);vertex:('id'->nat))[get,1,_])]]
inst domain range state
-------------------------------------------------------------------------------------------------------------------------------------------------------
[combine,(vertex<=int[as,nat<=int[is,boo... (int;int) => (vertex<=int[is,bool<=int[gt,0]][split,(...
[as,nat<=int[is,bool<=int[gt,0]]] int => nat{?}
[is,bool<=int[gt,0]] int => int{?}
[gt,0] int => bool
[as,vertex<=nat[split,('id'->nat)]] nat => vertex:('id'->nat)
[split,('id'->nat)] nat => ('id'->nat)
[as,nat<=int[is,bool<=int[gt,0]]] int => nat{?}
[is,bool<=int[gt,0]] int => int{?}
[gt,0] int => bool
[as,vertex<=nat[split,('id'->nat)]] nat => vertex:('id'->nat)
[split,('id'->nat)] nat => ('id'->nat)
[as,edge<=(vertex<=int[is,bool<=int[gt,0... (vertex<=int[is,bool<=int[gt,0]][split,(... => edge:('outV'->vertex<=(vertex:('id'->nat...
[split,('outV'->vertex<=(vertex:('id'->n... (vertex<=int[is,bool<=int[gt,0]][split,(... => ('outV'->vertex<=(vertex:('id'->nat);ver...
->[get,0,_] (vertex:('id'->nat);vertex:('id'->nat)) => vertex:('id'->nat)
->[get,1,_] (vertex:('id'->nat);vertex:('id'->nat)) => vertex:('id'->nat)
'
mmlang>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've been working on a concept I'm calling cascading coercion (or chained implicts). The general idea is that your API (a model in mm-ADT) is a bunch of types that are linked together in a graph by instruction paths that will yield one type from another type. If you are at a string and want to make that string a person, you simply do
'marko' => person
... the most efficient way of generating a person from a string is searched and computed.This graph is called the obj graph and it is of fundamental importance to nearly every process in mm-ADT.
https://www.mm-adt.org/vm/
Here is a simple property graph model. An mm-ADT model is a collection of types. Types are of the form
range<=domain[inst]
. Given a domain type, if you evaluate the sequence of instructions, then an obj of the range type is returned.NOTE: The model format below is just to help for human organization. It could just be a flat list. Ultimately, a model is a graph and a "flat list" is equivalent to an edge list.
A obj graph is constructed that links all these types by their domain and range. It also decomposes (bi-)products and links up the individual components.
Now, to say: "morph 5 into an
int
" you express that as below.SYNONYMS: morph, coerce, map, translate, ...
How about a
nat
(realize we imported thenum
package in the pg model above)?What does it look like compiled?
Let's create a (bi-)product.
Now lets have each component morph accordingly.
An edge is a reference to a 2-component product. There is a path from
(nat;vertex)
toedge
. It's:Thus:
...or let the compiler do the work for you -- an obj graph search from source to sink.