Skip to content

Instantly share code, notes, and snippets.

@okram
Created November 7, 2020 12:20
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/29f3f09830aeb43c5d6679201965eb38 to your computer and use it in GitHub Desktop.
Save okram/29f3f09830aeb43c5d6679201965eb38 to your computer and use it in GitHub Desktop.
mmlang> 5 => int+2-<(nat;nat+10)=(vertex;vertex)=>edge
==>edge:('outV'->vertex:('id'->nat:7),'inV'->vertex:('id'->nat:17))
mmlang> int => int+2-<(nat;nat+10)=(vertex;vertex)=>edge
==>edge<=int[plus,2]
[split,(nat{?}<=int[is,bool<=int[gt,0]];nat{?}<=int[is,bool<=int[gt,0]][plus,10])]
[combine,(vertex;vertex)]
[as,edge<=(vertex;vertex)
[split,('outV'->vertex<=(vertex;vertex)[get,0,_],
'inV'->vertex<=(vertex;vertex)[get,1,_])]]
@okram
Copy link
Author

okram commented Nov 7, 2020

The [explain] instruction provides a human readable breakdown of your types (which, if they are not base types, are composed of yet more types).

mmlang> (int;int) => edge => [explain]
==>'
edge<=(int;int)[combine,(vertex<=int[as,nat<=int[is,bool<=int[gt,0]]][as,vertex<=nat[split,('id'->nat)]];vertex<=int[as,nat<=int[is,bool<=int[gt,0]]][as,vertex<=nat[split,('id'->nat)]])<=(int;int)][as,edge<=(vertex<=int[is,bool<=int[gt,0]][split,('id'->nat)];vertex<=int[is,bool<=int[gt,0]][split,('id'->nat)])[split,('outV'->vertex<=(vertex:('id'->nat);vertex:('id'->nat))[get,0,_],'inV'->vertex<=(vertex:('id'->nat);vertex:('id'->nat))[get,1,_])]]

inst                                           domain                                              range                                         state
-------------------------------------------------------------------------------------------------------------------------------------------------------
[combine,(vertex<=int[as,nat<=int[is,boo...    (int;int)                                      =>   (vertex<=int[is,bool<=int[gt,0]][split,(...
 [as,nat<=int[is,bool<=int[gt,0]]]              int                                           =>    nat{?}
  [is,bool<=int[gt,0]]                           int                                          =>     int{?}
   [gt,0]                                         int                                         =>      bool
 [as,vertex<=nat[split,('id'->nat)]]            nat                                           =>    vertex:('id'->nat)
  [split,('id'->nat)]                            nat                                          =>     ('id'->nat)
 [as,nat<=int[is,bool<=int[gt,0]]]              int                                           =>    nat{?}
  [is,bool<=int[gt,0]]                           int                                          =>     int{?}
   [gt,0]                                         int                                         =>      bool
 [as,vertex<=nat[split,('id'->nat)]]            nat                                           =>    vertex:('id'->nat)
  [split,('id'->nat)]                            nat                                          =>     ('id'->nat)
[as,edge<=(vertex<=int[is,bool<=int[gt,0...    (vertex<=int[is,bool<=int[gt,0]][split,(...    =>   edge:('outV'->vertex<=(vertex:('id'->nat...
 [split,('outV'->vertex<=(vertex:('id'->n...    (vertex<=int[is,bool<=int[gt,0]][split,(...   =>    ('outV'->vertex<=(vertex:('id'->nat);ver...
  ->[get,0,_]                                      (vertex:('id'->nat);vertex:('id'->nat))      =>     vertex:('id'->nat)
  ->[get,1,_]                                      (vertex:('id'->nat);vertex:('id'->nat))      =>     vertex:('id'->nat)
'
mmlang>

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