Skip to content

Instantly share code, notes, and snippets.

View okram's full-sized avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
@okram
okram / cpu.groovy
Last active December 23, 2019 01:08
/***
create an obj with
1. the specified <= generator
2. the symbol 'cpu'
***/
cpu <=[choose,[
person -> ['name':str~name,'age':int] <= people~>[is,[get,'name'][eq,name]],
people -> person{*} <=[=mongo][get,'users'],
weight -> 0.0,
path -> [;],
/***********************************************
* ON THE NATURE OF THE MM-ADT TRAVERSER (RFC) *
***********************************************/
// the "traverser" is an obj just like any other obj.
// what makes it a "CPU" is that its "mapped from" instructions (<=) are prefixed with a [choose] instruction.
// more specifically, its a [choose] whose branches encode variables, schema, rewrites, whatever...
// the "traverser" obj can contain read/write state (variables/schema) and flow control (rewrites) (i.e. a register-based CPU).
// it is important to note that there is nothing special about variables, schema, rewrites, etc.
/**
BRANCHING IN mm-ADT
The Rogdopalous -- Winter 2019 [mm-adt.org]
The [branch] instruction takes an incoming obj and sends a clone of it
down each internal split/branch/fork.
There 4 different ways to express the same computation.
**/
mmlang> int=>[plus,4]=>y=>z=>[mult,20]=>int=>[explain]
int <= int~[plus,4][as,int~y][as,int~z][mult,20][as,int]
instruction domain range state
-----------------------------------------------------------------------------------------------
[plus,4] int => int -> []
[as,int~y] int => int -> [int~y <= int~[plus,4]]
[id] int~y => int~y -> [int~y <= int~[plus,4]]
[as,int~z] int => int -> [int~y <= int~[plus,4], int~z <= int~[plus,4][as,int~y]]
@okram
okram / stuff.groovy
Last active December 11, 2019 18:38
mmlang> 1602.65 + 1079.21 + 173.42 + 19.74
==>2875.0198
mmlang> real + 1602.65 + 1079.21 + 173.42 + 19.74 => [explain]
real <= real~[plus,1602.65][plus,1079.21][plus,173.42][plus,19.74]
instruction domain range
----------------------------------
[plus,1602.65] real => real
[plus,1079.21] real => real
mmlang> 1 => x
==>1~x
mmlang> 1 => x => [plus,2]
==>3
mmlang> 1 => x => [plus,2] => y
==>3~y
mmlang> 1 => x => [plus,2] => y => x
mmlang> 1 => x => [plus,2] => y => [minus,2] => x
==>1~x
mmlang>
Imagine this alternate utopia.
OSS developers register 1099s with Amazon.
Amazon aggreagates usage statistics of packages.
Amazon provides monthly royalty distributions.
In this alternate reality, developers would be falling over each other to start an Amazon OSS project.
People would quit their boring day jobs to earn royalties from their software.
Because its royalty based, when I'm in between "flow states," I still get paid.
// [=] instructions denote the boundary between one model and another.
// the traverser's model will have a different algebra than the model its moving through.
// - e.g. the internal state of the traverser uses different types than mongodb.
// - how do traversers split at branches?
// - how do traversers merge at joins?
// - when traversers merge, what are the rules for path aggregation?
// Perhaps [=] instructions are "rich" in that they store model definitions. (costume change)
// This could be how progamming libraries are expressed in mm-ADT?
// monad state such as path-histories are encoded using reflection and self-modifying instructions
**************************************************
* [choose, *
* [get,'value'] -> 5 *
* [get,'path'] -> [1,2,3,4] *
* [plus,[zero] -> [id] *
* [mult,[one]] -> [id] * *************************
* [minus,[zero]] -> [id] * => [plus,1] => * ...[get,'value'] -> 6 *
* inst -> [sideeffect, * *************************
// there are no records, only rewrite rules that simulate the behavior
*******************************
* [choose, *
* [get,'name'] -> 'marko', * ***********
* [get,'age'] -> 29, * => [get,'name'] => * 'marko' *
* [plus,[zero]] -> [id], * ***********
* [minus,[zero]] -> [id]] *
*******************************