Have a look at the join calculus and the "chemical abstract machine" as implemented in JoCaml, e.g., https://sites.google.com/site/winitzki/tutorial-on-join-calc...