Skip to main content

Dysfunctional programming in Python with all the side effects.

Project description

The readme is a work in progress.

Build StatusCoverage StatusPyPI version

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
reformatted poser.py
All done! ✨ 🍰 ✨
1 file reformatted.
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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

poser-0.2.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

poser-0.2.0-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page