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
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> 1 => 1
==>1
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> 1 => 1
==>1
@okram
okram / sugar.groovy
Last active November 27, 2019 16:10
mmlang> 5 > 10
==>false
mmlang> int > 10
==>bool <= [gt,10]
mmlang> > 10
==>[gt,10]
/*
The [explain] instruction builds a pretty-printable table of the
incoming object's instruction sequence's domains and ranges.
Every object has a "maps from" (<=) instruction sequence.
Instances are mapped from [id]. (i.e. no instructions needed to create it).
*/
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
// int[is[gt,30]] is a type. it denotes those integers greater than 30.
// when used in a computation, it behaves like any other type in that it provides type checking/inference capabilities.
// thus, this computation will yield 0 or 1 integers greater than 30.
mmlang> int[is[gt,30]] => [mult,2][plus,50][is,[gt,100]]
==>(int[is,[gt,30]]){?} <= [mult,2][plus,50][is,bool <= [gt,100]]
// note the [is,[lt,10]] instruction.
// the result of the type inference should have [is,[lt,10]] => [is,false] and thus, a dead branch.
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> int => (([id] + [plus,1] + [plus,2]) * [neg]) => [plus,[zero]][is,[gt,-3]]
~/software/mm-adt/vm/java bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> 1 => int
==>1
/**
This is now the general structure of an obj.
obj <= [x]
-a-> obj <= [x]
-b-> obj <= [x]
-c-> obj <= [x]
1. An obj has a "maps from" (<=) instruction sequence. This is how the obj is generated.
2. An obj has zero or more "state variables" (->). Their respective <= is computed every time the parent obj is mutated.
// there is an interesting algebra we need to define
mmadt> int{3} <= [start,1,2,3] // int{3} is a 'reference' to the stream 1,2,3
==>1
==>2
==>3
mmadt> int{3} <= [start,1,2,3] => int // the int{3} reference is => (mapped-to) the int type.
==>1 // the RHS int serves as a filter instruction (compiles to [is,[a,int]])
==>2
==>3
mmadt> '2' => [is,[or,[a,int],[eq,1]]][mult,6]
mmadt> 2.3 => [is,[or,[a,int],[eq,1]]][mult,6]
mmadt> 6 => [is,[or,[a,int],[eq,1]]][mult,6]
==>36
mmadt> 6 => [is,[or,[a,int],[eq,1]]] => [mult,6]
==>36
mmadt> true => [is,[or,[a,int],[eq,1]]] => [mult,6]
mmadt> 'a' => [is,[a,int|1]] => [mult,5]
mmadt> 15 => [is,[a,int|1]] => [mult,5]
==>75