This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
# |