A Neighborhood of Infinity
blog.sigfpe.com · Personal blog · on HN since 2009
Dan Piponi (sigfpe) writes on Haskell, category theory, mathematics, and physics, drawing on his background in visual effects.
What HN saysCommenters call it a must-read for the mathematically inclined, and "You Could Have Invented Monads" is regarded as a Haskell classic.
185HN people shared it
119linked it in comments
89stories submitted
930story points
4 months agolast shared
2009people per year2026
Most-shared posts
- 1You Could Have Invented Monads (And Maybe You Already Have)53 people · 47 points · first shared 2009 · 6 comments on HN
- 2A Neighborhood of Infinity22 people · 26 points · first shared 2009 · 2 comments on HN
- 3From Löb's theorem to spreadsheet evaluation7 people · 32 points · first shared 2012 · 5 comments on HN
- 4Data and Codata (2007)7 people · 26 points · first shared 2013 · discussion on HN
- 5Homepage7 people · first shared 2010
- 6Mother of all monads6 people · first shared 2013
- 7Why is nuclear fusion so hard?4 people · 177 points · first shared 2018 · 170 comments on HN
- 8Reasons to use Haskell as a Mathematician (2006)4 people · 143 points · first shared 2011 · 74 comments on HN
- 9A Neighborhood of Infinity: Quine Central4 people · 8 points · first shared 2011 · discussion on HN
- 10Evaluating cellular automata is comonadic (2006)4 people · 2 points · first shared 2010 · discussion on HN
- 11Haskell - The Trivial Monad (great intro with exercises)3 people · 48 points · first shared 2010 · 2 comments on HN
- 12Reverse Engineering Machines with the Yoneda Lemma (2006)3 people · 8 points · first shared 2014 · discussion on HN
- 13Quick and dirty reinversion of control3 people · 2 points · first shared 2011 · discussion on HN
- 14What Category Do Haskell Types and Functions Live In? (2009)3 people · 2 points · first shared 2012 · discussion on HN
- 15Lossless decompression and the generation of random samples2 people · 52 points · first shared 2012 · 6 comments on HN
What HN people wrote when they linked it
pygy_ · 2012-04-15
Dan Piponi (a.k.a. SIGFPE)[0] wrote a shader[1] that paints its own source code.
I don't think he published the code, because it was written for Renderman shaders at ILM, though.
His blog is a must read if you're mathematically inclined.
[0] http://blog.sigfpe.com/
[1] http://homepage.mac.com/sigfpe/SRTX2008.pdf
pjscott · 2010-11-27
The internet really helps with that, by expanding your world to include some people who are just dazzlingly brilliant, and remind you how far you have to go. This guy, for example:
http://blog.sigfpe.com/
The nice thing about this kind of ego-shrinking is that it's combined with inspiration to do something about it, rather than just feeling deflated. There's so much interesting stuff out there.
petesergeant · 2026-04-30
It took me a long time to write an explainer on embeddings, and one day I will finally finish my Monad tutorial. I think fundamentally you need to have needed them to solve a problem to get them, and outside of pure languages you have to do a lot of special-condition setup to explain why you need them. "You Could Have Invented Monads"[0] is probably my favourite existing one.
0: https://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.htm…
ddellacosta · 2026-02-06
Yeah this is such an important blog for Haskell.
A classic that everyone should read: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
I attended a talk of his at Papers We Love at Strange Loop in 2018, I didn't really read the description and I was vaguely expecting something Haskell related, and instead got this: https://www.youtube.com/watch?v=766obijdpuU
I could barely understand it, but was impressed by what I could grasp. Dan Piponi's range is amazing, dude is brilliant
sfvisser · 2025-11-15
Reminds me of this classic doing the same: http://blog.sigfpe.com/2006/11/from-l-theorem-to-spreadsheet.html?m=1
simlevesque · 2024-06-07
There's also this classic blogpost: http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.ht…
mikhailfranco · 2024-05-19
As an aside on an aside, there is also the related classic:
Conor McBride, The Derivative of a Regular Type is its Type of One-Hole Contexts
http://strictlypositive.org/diff.pdf
related to Huet's Zipper and Hinze, Paterson Finger Trees, with a huge of follow-on literature:
https://personal.cis.strath.ac.uk/conor.mcbride/Holes.pdf
https://conal.net/blog/posts/differentiation-of-higher-order-types
and numerous old posts by sigfpe (Dan Piponi), e.g.
http://blog.sigfpe.com/2008/06/blessed-mans-formula-for-holey.html
svieira · 2023-08-02
For those who follow along but don't do this for work or fun (yet) is this a Futamora projection? http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.ht…
Or is this a simpler form of static analysis / partial runtime optimization?
matt-noonan · 2023-01-13
It's definitely surprising, for a couple of reasons:
1. It isn't just the uninteresting result that the set of trees has the same cardinality as the set of 7-tuples of trees; the bijection here is given by a finite, non-looping program built out of `isEmpty : Tree -> Bool`, `getLeft : Tree -> Maybe Tree`, `getRight : Tree -> Maybe Tree`, and the constructors `empty : Tree` and `join : Tree x Tree -> Tree`
2. It isn't true for any number 1 < x < 7
3. In any case, why should it work out exactly? Why not "one tree can be encoded into seven trees, or one of these 13 remaining cases"?
The paper is quite good, but Dan Piponi has a great blog post that recasts the isomorphism as a game of "nuclear pennies", which is a fun puzzle to work out yourself: http://blog.sigfpe.com/2007/09/arboreal-isomorphisms-from-nuclear.html
erk__ · 2023-01-11
One of my favourite things about the question between compilers and interpreters is the Futamura projections [0] which is a way of using partial evaluation to construct both things. It could be interesting if we see that getting used more explicit than something like GraalVM which one could argue is getting there. [1]
[0]: http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.ht…
[1]: https://news.ycombinator.com/item?id=18995651 (and the parent: https://news.ycombinator.com/item?id=18995498)
renewiltord · 2022-11-14
You Could Have Invented Monads for the utility of the program syntax+pattern that is a monad http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
Also the original perceptron stuff for why NNs work, but I don't think that has general utility. The tools work irrespective of knowing why they work so I wouldn't recommend that for a SWE.
burkaman · 2022-02-13
I also found the style in this article kind of annoying and difficult to follow, but I think "discovery fiction" usually means something different. The two examples Michael Nielsen gives are https://michaelnielsen.org/ddi/how-the-bitcoin-protocol-actually-works… and https://michaelnielsen.org/ddi/why-bloom-filters-work-the-way-they-do/… Another classic example is http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html…
You can see there's no dialogue; the idea is to frame an article as "how might you discover/invent this concept on your own", rather than just directly explaining how a thing works. You are given a fictional goal, and you "discover" the subject matter by building iterative solutions.
whycombinater · 2021-12-10
Regarding the "pedagogy", my favorite method of learning is straightforward problem solving: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
If you wanted to have state with pure functions, you would, according to DRY, be compelled to write the bind operator. You wouldn't have known to call it a monad or why some basement theoretician likens it to a burrtiofunctor, but you nevertheless would have made the obvious coding solution.
Is this possible for rotation without a PhD in geometry or algebra?
raphlinus · 2020-09-07
Yupyup. For those of us who don't just automatically know what a semigroup action is, Dan Piponi's blog on using monoids to do incremental regular expression matching is probably a good read: http://blog.sigfpe.com/2009/01/fast-incremental-regular-expression.htm…
chowells · 2020-08-29
There's also the classic http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
Written by a 3-time Oscar winner, no less!
svat · 2020-01-11
More precisely, all well-defined computable functions are continuous.
For another exposition of the same (or similar) results, see also Dan Piponi's post from 2008 "What does topology have to do with computability?" at http://blog.sigfpe.com/2008/01/what-does-topology-have-to-do-with.html
Also, as a follow-up, you may be interested in Martin Escardo's 2007 post on the same blog: http://math.andrej.com/2007/09/28/seemingly-impossible-functional-prog…
peteretep · 2019-08-05
> I'm fifteen years old with good knowledge of mostly high school level math, and may have missed some parts.
Kabir,
Great work on getting this done. I wonder if looking around for and mentioning the similar "You Could Have Invented Monads"[0] would be a good move
[0] http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
Tyr42 · 2018-07-16
Just to add more different explanations, since that'll help.
http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
This one is my favourite, and does it well by example and walking through three different cases, then generalizing.
mrkgnao · 2017-05-06
For one, I often read Dan Piponi[0] / sigfpe's articles on my phone, and they sometimes have long equations that stretch off the page. If you drag the page in the commonsense way, you end up moving to another post, as you say: I've somehow subconsciously learned to drag at an angle and then correct by scrolling up or down as needed. It's sad that it has to be done, but it works.
[0]: Here's a delightful classic with pictures: http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.ht…
ekidd · 2017-04-03
Category theory is mostly useful if you're getting very deep into Haskell, or if—for some reason—you need to generalize the lamba calculus to handle strange new kinds of computations.
In particular, the lamba calculus is closely related to Cartesian closed categories, which are in turn related to topoi (which are used in many cases of mathematical logic). And from there it's a small leap to probability and generalizations of probability theory.
So basically, if you're a programming language designer with esoteric tastes, category theory contains some great abstractions.
Here's an example showing how to represent quantum superposition as a monad: http://blog.sigfpe.com/2007/02/monads-for-vector-spaces-probability.ht… If this kind of thing makes you drool, go learn some category theory. :-)
seansh · 2017-03-19
The original Haskell version is also worth a read http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
merijnv · 2015-07-15
To be fair, I don't know a single person that explains things using
> "just a monoid in the category of endofunctors"
In fact, even among people who DO know the category theory necessary to understand this expression it's considered a very obtuse and useless explanation. Especially in the context of Haskell.
As for good readable introductions, I consider Wadler's paper "Monads for Functional Programming" to actually be a pretty good introduction. Another good intro is "You Could Have Invented Monads! (And Maybe You Already Have.)" http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
mlitchard · 2015-04-06
In no particular order
Dan Piponi
http://blog.sigfpe.com/
The ever awesome oleg
http://okmij.org/ftp/
Chris Done
http://chrisdone.com/
Gabriel Gonzalez
http://www.haskellforall.com/
There are many more. The haskell community has awesome developers in abundance.
throwaway283719 · 2014-09-12
The whole point about monads is that they provide a uniform interface for working with values that carry some extra context. The genericity of the interface is nice, in that it allows you to write generic monad combinators, but they are only useful because of the context (effects, control flow, etc). If you don't describe any of the implementations, you are missing the point!
The best introduction to monads was written in 2006 (more than eight years ago now) and I don't imagine that a better one will be written in the near future -
http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
codygman · 2014-07-18
Monads are useful and unknowingly created in other languages all the time [0].
If you aren't quite comfortable enough with monads to follow the first link, I found this implementing monads in python tutorial[1] to be a huge help.
For those that want to play with Monads in Python, check out PyMonad[2].
0: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
1: http://www.valuedlessons.com/2008/01/monads-in-python-with-nice-syntax…
2: https://pypi.python.org/pypi/PyMonad/
mercurial · 2014-07-10
On the other hand, the classic http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html takes you (gently) through code, and you find out at the end that you have written a monad.
crntaylor · 2013-12-24
It wasn't meant to be a criticism of your implementation - just a comparison of the two languages for this particular task. Haskell happens to be very concise for writing mathematical code. I love Python too, but for different reasons (easy to prototype, great libraries, flexible).
I've noticed that people with a mathematical background tend to be very attracted to Haskell. There's a great blog post by Dan Piponi enumerating eleven reasons to use Haskell as a mathematician:
http://blog.sigfpe.com/2006/01/eleven-reasons-to-use-haskell-as.html
paulkoer · 2013-12-20
I recommend: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
But in the end I think for most people 'understanding' the concept of monads is just something that is not to be had within a couple of hours. It takes a little bit of patience thinking about them and using them for a while.
asdasf · 2013-09-30
I probably can't help you much there, I think LYAH is pretty good. Are you trying to avoid learning monads, or you want a different approach to learning them? I think this is the best explanation of monads: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html
GHC itself is a good example project to look at, the base libraries tend to all be pretty idiomatic. Xmonad is a good option too.
egonschiele · 2013-06-11
Post author here. If you tell me where you're stumbling, I might be able to fix it.
You could also check out this post by sigfpe, one of my favorite posts on monads: http://blog.sigfpe.com/2006/08/you-could-have-invented-monads-and.html