Skip to content

Instantly share code, notes, and snippets.

View asarephilip's full-sized avatar

Philip Boadu Asare asarephilip

View GitHub Profile
@asarephilip
asarephilip / gist:d38dccf503e53b2057e30b75a21c1b50
Created July 22, 2022 03:06 — forked from Niriel/gist:5311471
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