obfusk.py - functional programming (& other tools) library for python (2+3)
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
obfusk
.gitignore
.travis.yml
MANIFEST.in
Makefile
README.md
setup.cfg
setup.py

README.md

[]: {{{1

File        : README.md
Maintainer  : Felix C. Stegerman <flx@obfusk.net>
Date        : 2016-10-20

Copyright   : Copyright (C) 2016  Felix C. Stegerman
Version     : v0.0.1

[]: }}}1

PyPI version Build Status

Description

obfusk.py - functional programming (& other tools) library for python (2+3)

See obfusk/*.py for the code (with examples).

Examples

>>> # Immutable base class
>>> from obfusk import Immutable
>>> class Maybe(Immutable): pass
>>> class Just(Maybe):
...   __slots__ = "value".split()
...   def __init__(self, value):
...     super(Just, self).__init__(value = value)
>>> class Nothing(Maybe): pass
>>> x, y = Just(42), Nothing()
>>> x
Just(value = 42)
>>> y
Nothing()
>>> x.value
42
>>> # lazy list
>>> fibs = llist([0, 1], rec = lambda fibs:
...        ( m+n for m,n in izip(fibs, fibs[1:]) ))
>>> list(fibs[:10])
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

...

Specs & Docs

$ python -mobfusk -v                # run tests
$ python -mcoverage run -m obfusk   # test coverage
$ python -mcoverage html            # generate html report
$ pydoc obfusk                      # view docs

TODO

  • proper algebraic data types?
  • ...

License

LGPLv3+ [1].

References

[1] GNU Lesser General Public License, version 3 --- https://www.gnu.org/licenses/lgpl-3.0.html

[]: ! ( vim: set tw=70 sw=2 sts=2 et fdm=marker : )