Giter Site home page Giter Site logo

unpythonic's Introduction

Unpythonic: Python meets Lisp and Haskell

In the spirit of toolz, we provide missing features for Python, mainly from the list processing tradition, but with some Haskellisms mixed in. We place a special emphasis on clear, pythonic syntax. These features make up the pure-Python core of unpythonic, and are meant to be used directly. We also provide extensions to the Python language as a set of syntactic macros that are designed to work together. Each macro adds an orthogonal piece of functionality that can (mostly) be mixed and matched with the others.

The macros provide an extension to the pure-Python layer, and offers features such as automatic currying, automatic tail-call optimization, lexically scoped let and do with lean syntax, and implicit return statements. Some of these macro features, like call-by-need (lazy functions), continuations (call/cc), and easy-to-use multi-expression lambdas with local variables, are not available in the pure-Python layer. Additionally, some pure-Python features like batteries for itertools do not have a macro layer equivalent. Check the documentation for the full sets of features.

The design considerations of unpythonic are based in simplicity, robustness, and with minimal dependencies. See our design notes for more information.

Dependencies

Currently none required.
MacroPy optional, to enable the syntactic macro layer.

Documentation

Pure-Python feature set
Syntactic macro feature set: the second half of unpythonic.
Design notes: for more insight into the design choices of unpythonic

Installation

PyPI

pip3 install unpythonic --user

or

sudo pip3 install unpythonic

GitHub

Clone (or pull) from GitHub. Then,

python3 setup.py install --user

or

sudo python3 setup.py install

Uninstall

Uninstallation must be invoked in a folder which has no subfolder called unpythonic, so that pip recognizes it as a package name (instead of a filename). Then,

pip3 uninstall unpythonic

or

sudo pip3 uninstall unpythonic

License

2-clause BSD.

Dynamic assignment based on StackOverflow answer by Jason Orendorff (2010), used under CC-BY-SA. The threading support is original to our version.

Core idea of lispylet based on StackOverflow answer by divs1210 (2017), used under the MIT license.

Core idea of view based on StackOverflow answer by Mathieu Caroff (2018), used under the MIT license. Our additions include support for sequences with changing length, write support, iteration based on __iter__, in-place reverse, and the abstract base classes.

Acknowledgements

Thanks to TUT for letting me teach RAK-19006 in spring term 2018; early versions of parts of this library were originally developed as teaching examples for that course. Thanks to @AgenttiX for feedback.

The trampoline implementation of unpythonic.tco takes its remarkably clean and simple approach from recur.tco in fn.py. Our main improvements are a cleaner syntax for the client code, and the addition of the FP looping constructs.

Another important source of inspiration was tco by Thomas Baruchel, for thinking about the possibilities of TCO in Python.

Python-related FP resources

Python clearly wants to be an impure-FP language. A decorator with arguments is a curried closure - how much more FP can you get?

Old, but interesting:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.