import logging, sys
logging.basicConfig(
format='%(message)s',
stream=sys.stdout,
level=logging.INFO,
)
from joy.utils.types import (
doc_from_stack_effect,
infer,
reify,
unify,
FUNCTIONS,
JoyTypeError,
)
D = FUNCTIONS.copy()
del D['product']
globals().update(D)
fi, fo = infer(pop, swap, rolldown, rrest, ccons)[0]
print doc_from_stack_effect(fi, fo)
from joy.parser import text_to_expression
from joy.utils.stack import stack_to_string
e = text_to_expression('0 1 2 [3 4]') # reverse order
print stack_to_string(e)
u = unify(e, fi)[0]
u
g = reify(u, (fi, fo))
print doc_from_stack_effect(*g)
e = text_to_expression('[2 3]')
u = unify(e, fo)[0] # output side, not input side
u
g = reify(u, (fi, fo))
print doc_from_stack_effect(*g)
fi, fo = infer(dup, mul)[0]
e = text_to_expression('"two"')
print stack_to_string(e)
try:
unify(e, fi)
except JoyTypeError, err:
print err