Skip to content

Instantly share code, notes, and snippets.

View slapglif's full-sized avatar

Michael Brown slapglif

View GitHub Profile
@Niriel
Niriel / gist:5311471
Created April 4, 2013 15:37
A Python implementation of Arrows (such as seen in Haskell).
#! /usr/bin/python
"""Implementation of the arrow abstraction for functions.
Abstracting functions with Arrows has advantages. Arrows make it very easy to
compose functions (by simply 'multiplying' them with the `*` operator). The
order in which the arrows are written match the order of the computations,
making long pipelines easy to work with. Arrows also provide mechanisms for
creating and merging branches, which helps when a value needs to be consumed by
several functions, or when a function needs values from several sources. Arrows
can also support conditional application, selecting which of two functions f and