Skip to content

Instantly share code, notes, and snippets.

@okram
Last active November 26, 2019 17:18
Show Gist options
  • Save okram/d848deec59b8dd65ffa96f1f2240dfe1 to your computer and use it in GitHub Desktop.
Save okram/d848deec59b8dd65ffa96f1f2240dfe1 to your computer and use it in GitHub Desktop.
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> int => (([id] + [plus,1] + [plus,2]) * [neg]) => [plus,[zero]][is,[gt,-3]]
==>int{?} <= [neg][plus,0][is,bool <= [gt,-3]]
==>int{?} <= [plus,1][neg][plus,0][is,bool <= [gt,-3]]
==>int{?} <= [plus,2][neg][plus,0][is,bool <= [gt,-3]]
mmlang> 1 => (([id] + [plus,1] + [plus,2]) * [neg]) => [plus,[zero]][is,[gt,-3]]
==>-1
==>-2
mmlang>
/*
When you provide int as the input to the computation,
what is returned are the three mutations that int
will undergo. This is known as type checking and inference.
Realize that + and * are operators in the instruction ring.
In stream ring theory, + is a cloning branch and compiles to
[branch,[id],[plus,1],[plus,2]]
Thus, in full:
[branch,[id],[plus,1],[plus,2]][neg][plus,[zero]][is,[gt,-3]]
When you provide 1 as the input to the computation,
each branch is computed and those branch outputs that are > -3 are returned.
This is known as instance evaluation.
Note that the branch quantifiers were int{?} ---
stating that 0 or 1 int will come through that branch.
Finally, [inst]=>[inst] is equivalent to "maps to"-operator
[inst][inst] is equivalent to "concat"-operator
[inst]*[inst]. "compose"-operator.
In the instruction ring, they all have the same behavior.
This is not generally true across all rings. For example, in the
int ring:
mmlang> 1 => int
==>1
mmlang> 1*int
==>int <= [start,1][mult,int]
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment