diff --git a/gooey/gui/util/casting.py b/gooey/gui/util/casting.py new file mode 100644 index 0000000..8e90544 --- /dev/null +++ b/gooey/gui/util/casting.py @@ -0,0 +1,15 @@ + + +def safe_int(n): + return _safe_cast(int, n) + +def safe_float(n): + return _safe_cast(float, n) + + +def _safe_cast(_type, val): + try: + return _type(val) + except ValueError: + return None + diff --git a/gooey/gui/util/functional.py b/gooey/gui/util/functional.py new file mode 100644 index 0000000..8d0c8d4 --- /dev/null +++ b/gooey/gui/util/functional.py @@ -0,0 +1,10 @@ +''' +Simple monad-ish bindings +''' + + +def unit(val): + return val + +def bind(val, f): + return f(val) if val else None