Skip to content

Instantly share code, notes, and snippets.

@okram
Last active November 12, 2019 11:58
Show Gist options
  • Save okram/d0ba7cc14f28c5132ff516e3f3fa10e5 to your computer and use it in GitHub Desktop.
Save okram/d0ba7cc14f28c5132ff516e3f3fa10e5 to your computer and use it in GitHub Desktop.
Computing via Model Coupling
----------------------------
/**
The obj in mm-ADT and the traverser in TP3 wrap some primitive data type and
decorate the primitive with extra computaitonal metadata. These decorations
transform what would be a regular expression into a more expressive structure (memory).
Here are the current "decorations" over obj in mm-ADT.
**/
<- rewrite
<= access
/**
1. Path history with bifurcating objs (at branches) diverge from a shared geneology.
2. Loop stack w/ labels for pushing how many times a paritcular [repeat] has gone through.
3. Sack w/ labels for storing side data such as monoidal structures (compressable) -- counters, weights, etc.
4. Positive naturals as bulk (in TP3), but now arbitrary rings as coefficients in mm-ADT.
The morphisms begin at once!
The smallest object is the primitive value: int, bool, str, real.
*/
[int, // the primitive data type
[(str,obj)*] <=[=path] // a path map [http://tinkerpop.apache.org/docs/current/reference/#path-step]
<-[-path] * [a,map~x] <- x + obj{0} <=[=path][put,'a',[id]], // any time a map-instruction evaluated on an instance of this form, the current obj is stored in the [=path] storage system (main-memory).
int <=[=loop] // the loop counter for repeat (not a stack, so no nested loops allowed)
<-[-loop] * [emit] <- [=loop][drop] | // drop the loop counter when breaking out of the loop
[until] <- [=loop][plus,1] | // incr the loop counter when entering an predicate check
[repeat <- [error,'no nested loops']]] // no nested loops allowed -- its just an int counter
/*
The "Traverser Monad" gets tatted up with data structures and instruction rewrites as needed to express the semantics
of the operations...just build and build out the primitive data type with complexity via obj and inst mappings.
*/
Assume the above structure containing the primitive value, a labeled path map, and a int loop counter
is called OPR_Traverser -- traverser.
[start,t1,t2][plus,2]
|________ this triggers the rewrite_______
|
[start,t1,t2][branch,obj{0} <=[=path][put,'a',[id]],
[plus,2]]
@okram
Copy link
Author

okram commented Nov 12, 2019

Screen Shot 2019-11-11 at 7 39 52 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment