kykosic / pycats Goto Github PK
View Code? Open in Web Editor NEWFunctional Python with Typeclasses and Categories
License: Apache License 2.0
Functional Python with Typeclasses and Categories
License: Apache License 2.0
Example:
from pycats import Result
@Result.wrap
def divide(a, b):
return a / b
d = divide(2, 0)
d.unwrap()
Will give a traceback like:
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-1-e472ddea34ee> in <module>
9 d = divide(2, 0)
10
---> 11 d.unwrap()
pycats/pycats/data/result.py in unwrap(self)
163 def unwrap(self):
164 if isinstance(self.value, Exception):
--> 165 raise self.value
166 return self.value
pycats/pycats/data/result.py in wrapped_func(*args, **kwargs)
110 def wrapped_func(*args, **kwargs):
111 try:
--> 112 return Ok(func(*args, **kwargs))
113 except Exception as e:
114 return Err(e)
<ipython-input-1-e472ddea34ee> in divide(a, b)
4 @Result.wrap
5 def divide(a, b):
----> 6 return a / b
7
8
ZeroDivisionError: division by zero
It would be helpful if the traceback included the line which actually called the wrapped function:
d = divide(2, 0)
instead of skipping from the .unwrap()
call straight to inside the wrapped function. In a long chain of operations, it could be difficult to debug which operation was causing the exception.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.