Browse Source

functional tools for gooey

pull/150/head
chriskiehl 9 years ago
parent
commit
e7b5601a88
2 changed files with 25 additions and 0 deletions
  1. 15
      gooey/gui/util/casting.py
  2. 10
      gooey/gui/util/functional.py

15
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

10
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
Loading…
Cancel
Save