Dysfunctional programming in Python with all the side effects.
Project description
The readme is a work in progress.
Be a poser
poser
is a fluent interface for lazy, (dis)functional python programming.
pip install poser
disfunctional programming === Functional programming with all the side effects.
poser
API
from poser import λ, Composition, Λ, watch
from toolz.curried import *; from toolz.curried.operator import *
Chainable function compositions
λ composes a higher-order function that will pipe
a set of arguments and keywords through an ordered list of functions.
f = (
λ.range()
.map(
λ.mul(10))
.list())
This composition is compared below with a toolz.compose, toolz.pipe, and standard lib python.
assert f(10) \
== compose(list, map(mul(10)), range)(10) \
== pipe(10, range, map(mul(10)), list) \
== list(map(mul(10), range(10)))
The explicit api
The api above uses shortcuts to modules that a hasty programmer may prefer. The explicit api accesses functions by their package names first.
g = λ.builtins.range().map(
λ.operator.mul(10)
).builtins.list()
Imports
poser
will import modules if they are not available. For example, if pandas
is not __import__ed then poser
will __import __ it.
λ.pandas.DataFrame()
Symbollic composition
assert (λ[range] * λ.mul(10) + list)(10) == f(10)
if __name__== '__main__':
!jupyter nbconvert --to markdown readme.ipynb
!ipython -m poser
[NbConvertApp] Converting notebook readme.ipynb to markdown
[NbConvertApp] Writing 1600 bytes to readme.md
[NbConvertApp] Converting notebook poser.ipynb to python
[NbConvertApp] Writing 14787 bytes to poser.py
[1mreformatted poser.py[0m
[1mAll done! ✨ 🍰 ✨[0m
[1m1 file reformatted[0m.[0m
Fixing /Users/tonyfast/poser/poser.py
]0;IPython: tonyfast/poserTestResults(failed=0, attempted=67)
Name Stmts Miss Branch BrPart Cover
--------------------------------------------
poser.py 196 0 69 0 100%
parsing /Users/tonyfast/poser/poser.py...
]0;IPython: tonyfast/poser<IPython.core.display.SVG object>
parsing /Users/tonyfast/poser/poser.py...
<IPython.core.display.SVG object>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.