Skip to content

Instantly share code, notes, and snippets.

View sampottinger's full-sized avatar

A Samuel Pottinger sampottinger

View GitHub Profile
@nvanderw
nvanderw / functors.py
Created August 21, 2012 07:19
Typeclass stuff in Python
import itertools
# Monad instance on a Python iterator, very similar to Haskell's list monad.
# In general, Haskell typeclass instances can be regarded as dictionaries which
# map the implemented function to its implementation. For a good explanation of
# this, see Philip Wadler's "Faith, Evolution, and Programming Languages"
# lecture. What this means for us is that we can write a function whose type
# signature in Haskell would be:
# Monad m => f m
#