Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
Created November 25, 2019 18:00
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 saulshanabrook/0aa41609017516b3029a4f8ec23c6087 to your computer and use it in GitHub Desktop.
Save saulshanabrook/0aa41609017516b3029a4f8ec23c6087 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import metadsl_core as mc\n",
"import metadsl_visualize"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"@mc.Abstraction.from_fn\n",
"def double(x: mc.Integer) -> mc.Integer:\n",
" return x + x"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/x.typez+json": {
"nodes": {
"-121872347357726363": [
"1",
{
"args": [
"-4802478486240915350",
"4706879825357240146"
],
"function": "Abstraction.create",
"type_params": {
"T": {
"type": "Integer"
},
"U": {
"type": "Integer"
}
}
}
],
"-4802478486240915350": [
"3",
{
"args": [
"-9215065800760101096"
],
"function": "Abstraction.create_variable",
"type_params": {
"T": {
"type": "Integer"
},
"U": {
"type": "Integer"
}
}
}
],
"-8978635339804191002": [
"1",
{
"args": [
"3668765833563483275"
],
"function": "Abstraction.from_fn"
}
],
"-9215065800760101096": [
"2",
{
"repr": "4569664368",
"type": "Variable"
}
],
"3668765833563483275": [
"0",
{
"repr": "<function double at 0x110b75598>",
"type": "function"
}
],
"4706879825357240146": [
"4",
{
"args": [
"-4802478486240915350",
"-4802478486240915350"
],
"function": "Integer.__add__"
}
]
},
"states": {
"initial": "-8978635339804191002",
"states": [
{
"node": "-121872347357726363",
"rule": "metadsl_core.abstraction.Abstraction.from_fn"
},
{
"label": "core",
"node": "-121872347357726363",
"rule": ""
}
]
}
},
"text/plain": [
"Typez(definitions=None, nodes={'3668765833563483275': ['0', PrimitiveNode(type='function', repr='<function double at 0x110b75598>')], '-8978635339804191002': ['1', CallNode(function='Abstraction.from_fn', type_params=None, args=['3668765833563483275'], kwargs=None)], '-9215065800760101096': ['2', PrimitiveNode(type='Variable', repr='4569664368')], '-4802478486240915350': ['3', CallNode(function='Abstraction.create_variable', type_params={'U': DeclaredTypeInstance(type='Integer', params=None), 'T': DeclaredTypeInstance(type='Integer', params=None)}, args=['-9215065800760101096'], kwargs=None)], '4706879825357240146': ['4', CallNode(function='Integer.__add__', type_params=None, args=['-4802478486240915350', '-4802478486240915350'], kwargs=None)], '-121872347357726363': ['1', CallNode(function='Abstraction.create', type_params={'U': DeclaredTypeInstance(type='Integer', params=None), 'T': DeclaredTypeInstance(type='Integer', params=None)}, args=['-4802478486240915350', '4706879825357240146'], kwargs=None)]}, states=States(initial='-8978635339804191002', states=[State(node='-121872347357726363', rule='metadsl_core.abstraction.Abstraction.from_fn', label=None), State(node='-121872347357726363', rule='', label='core')]))"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"double"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment