diff --git a/phosphorus/phival.py b/phosphorus/phival.py index e1fd91b..57e8cae 100644 --- a/phosphorus/phival.py +++ b/phosphorus/phival.py @@ -3,6 +3,7 @@ from numbers import Number import builtins; import ast import re; import time + from .parse import Span, errors_on, log, debugging ip = get_ipython() @@ -633,6 +634,10 @@ def type(x): if x is None: return ConstantVal('t') # small hack for uninterpretable lambda bodies + from .semval import SemLiteral + if isinstance(x, SemLiteral): # can't check equality of SemLiterals + return ConstantVal("t") + for t in SemType.D: if x in SemType.D[t]: return ConstantVal(t) @@ -816,7 +821,8 @@ def ext(f,domain=map(ConstantVal,SemType.D["e"]),memoize=True): return out except Exception as e: #raise e - return Span.parse(f"ext({f})") + from .semval import SemLiteral + return SemLiteral(f"ext({f})") def ι(f, domain=None): try: diff --git a/phosphorus/semval.py b/phosphorus/semval.py index 01ab1f7..25ed3e3 100644 --- a/phosphorus/semval.py +++ b/phosphorus/semval.py @@ -53,6 +53,10 @@ def __ror__(self,other): def __invert__(self): return SpanVal("¬" + self) + # NOTE: a little dangerous, since we basically can't compare SemLiterals + def __eq__(self,other): + return opcode(self, "==", other) + # Since SemLiterals do not have a known value, we don't want them # short-circuiting boolean "and" and "or" in python. # We use & and | instead