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
mmlang> 6-<[+1;+2;+3]
==>[7;8;9]
mmlang> 6-<[+1;+2;+3]>-
==>7
==>8
==>9
mmlang>
// -< [split]
// >- [merge]
// [x|y] co-product
// variants are "choose"-branching structures
mmlang> 10-<[bool|int]
==>[|10]
mmlang> true-<[bool|int]
==>[true|]
mmlang> obj[=mmkv,'data/mmkv.mm'][is.v.name=='poop'][is.k>100 -> .v.age | is.k>11 -> .v.age+34 | obj -> .v.age][plus,100][fold,'seed',0,int[plus<seed>]][explain]
==>str<=[start,'
int{*}<=obj[=mmkv,'data/mmkv.mm'][is,bool{*}<=mmkv{*}[get,'v'][get,'name'][eq,'poop']][choose,[mmkv{*}[is,bool{*}<=mmkv{*}[get,'k'][gt,100]]:int{*}<=mmkv{*}[get,'v'][get,'age']|mmkv{*}[is,bool{*}<=mmkv{*}[get,'k'][gt,11]]:int{*}<=mmkv{*}[get,'v'][get,'age'][plus,34]|obj['k':int,'v':rec['name':str,'age':int]]{*}:int{*}<=mmkv{*}[get,'v'][get,'age']]][plus,100][fold,'seed',0,int[plus,int<seed>]]
instruction domain range state
-------------------------------------------------------------------------------------------------------------------------------------------------------------
[=mmkv,'data/mmkv.mm'] obj => mmkv['k':int,'v':rec['name':str
~/software/mm-adt/vm/jvm bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
// the mmkv model guarantees

One More Saturday Night with mm-ADT

Via Wikipedia:

  • An intentional definition gives the meaning of a term by specifying necessary and sufficient conditions for when the term should be used.
  • An extensional definition of a concept or term formulates its meaning by specifying its extension, that is, listing every object that falls under the definition of the concept or term in question.

Intentional Type Construction

When the traverser starts at a type (`obj{0}`), the traverser yields a type checked and compiled type.
The technique is called *abstract interpretation*.
```groovy
mmlang> obj{0}[=mmkv,'data/mmkv.mm'][get,'v'][is,[get,'age',int][gt,28]][get,'name'][plus,'!']
==>str{*}<=[=mmkv,'data/mmkv.mm'][get,'v'][is,bool{*}<=rec['name'->str,'age'->int]{*}[get,'age'][gt,28]][get,'name'][plus,'!']
```
When you append an `[explain]` instruction, the traverser walks his current type reference and creates a `str`
table representation of the domain/range of all the types used in the composition.

Taking Your mm-ADT Traverser for a Walk

by: Marko A. Rodriguez (Spring 2020)

http://mm-adt.org

mmlang> [plus,1]<x>[plus,0][plus,[mult,<x>]]
==>[plus,1]<x>[plus,0][plus,[mult,<x>]]
// general type casting w/ [as]
mmlang> 5[as,str]
==>'5'
mmlang> '5'[as,int]
==>5
mmlang> '5'[as,int][as,str]
==>'5'
// create records with [as] and traverser state
mmlang> int[plus,1]<x>[mult,10]<y>[as,rec['X'-><x>,'Y'-><y>,'Z'->[as,rec['XX' -> <x> + <y>]]]]
~/software/mm-adt/vm/jvm bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> [=mmkv,'data/mmkv.mm']
==>[=mmkv,'data/mmkv.mm']
~/software/mm-adt/vm/jvm bin/mmadt.sh
_____ _______
/\ | __ |__ __|
_ __ ___ _ __ ___ _____ / \ | | | | | |
| '_ ` _ \| '_ ` _ |_____/ /\ \| | | | | |
| | | | | | | | | | | / ____ \ |__| | | |
|_| |_| |_|_| |_| |_| /_/ \_\____/ |_|
mm-adt.org
mmlang> 1[=mmkv,'mmkv-2.txt']
==>['k'->1,'v'->['name'->'marko','age'->29]]