Zippers: Making Functional "updates" Efficient (2010)
Posted3 months agoActive3 months ago
goodmath.orgTechstory
calmpositive
Debate
20/100
Functional ProgrammingData StructuresZippers
Key topics
Functional Programming
Data Structures
Zippers
The post discusses the concept of zippers, a data structure that enables efficient updates to immutable data structures, and the discussion revolves around its applications, benefits, and potential use cases.
Snapshot generated from the HN discussion
Discussion Activity
Active discussionFirst comment
1h
Peak period
14
0-12h
Avg / period
7.5
Comment distribution15 data points
Loading chart...
Based on 15 loaded comments
Key moments
- 01Story posted
Oct 9, 2025 at 7:07 AM EDT
3 months ago
Step 01 - 02First comment
Oct 9, 2025 at 8:13 AM EDT
1h after posting
Step 02 - 03Peak activity
14 comments in 0-12h
Hottest window of the conversation
Step 03 - 04Latest activity
Oct 14, 2025 at 5:53 AM EDT
3 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 45526042Type: storyLast synced: 11/20/2025, 1:32:57 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
A concrete example is for managing the active item in a list. Instead of storing the active item as an index into the vector like this:
...which two the glaring impossible states. The vector can be empty, or the index can be outside the vector. Each time the active item is desired, we must check the index against the current state of the list.Instead, we can use the zipper concept so we always have a concrete active item:
Switching to a different active item requires some logic internal to the data structure, but accessing the active item always results in a concrete instance with no additional checks required.[0]: https://sporto.github.io/elm-patterns/basic/impossible-state...
It's the API that makes something impossible to misuse, and they could offer the same API like List.create(x: T, xs: T[]), but the first one is simpler.
- https://grishaev.me/en/clojure-zippers/
https://github.com/xdavidliu/fun-problems/blob/main/zipper-t...
https://web.archive.org/web/20160328032556/http://www.goodma...
https://journals.sagepub.com/doi/abs/10.3233/FUN-2005-651-20...