Skip to content

Instantly share code, notes, and snippets.

@okram
Last active August 21, 2020 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save okram/683a8ebc62d16914304365ccdf295d3b to your computer and use it in GitHub Desktop.
Save okram/683a8ebc62d16914304365ccdf295d3b to your computer and use it in GitHub Desktop.
// The mm model-ADT
// The base model on which all other mm-ADT models are built.
// ... a subset presented below.
mm:('type' -> (bool -> (bool),
int -> (int),
real -> (real),
str -> (str),
lst -> (lst),
rec -> (rec)),
'path' -> (_ -> ((_)<=([id])),
int -> ((int)<=(int[neg][neg]),
(int)<=(int[plus,0]),
(int)<=(int[mult,1]),
([1])<=(int[one]),
([0])<=(int[zero]),
([0])<=(int[mult,0]))))
///////////////////////////////////////////////
/**
With no model, instructions can only be concatenated to types (the free inst monoid).
With a model (and respective path equivalences), the path int-->[one] is equivalent to the identity path 1.
**/
mmlang> int[one]
==>int[one]
mmlang> :[model,'model/mm.mm']
mmlang> int[one]
==>1
/**
A few more examples
**/
mmlang> int[neg][neg]
==>int
mmlang> int[plus,0]
==>int
mmlang> int[plus,0][id][mult,1]
==>int
mmlang> int[plus,0][id][mult,57]
==>int[mult,57]
@okram
Copy link
Author

okram commented Aug 21, 2020

The reason that path equivalence domain and ranges are wrapped in a poly is due to "lifting." poly (lst/rec) is the foundation of the metaprogramming theory of mm-ADT.

image

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