Would love to see this for Haskell as well for comparison (both a simple, idiomatic solution as well as a more optimized approach via profiling)
https://chrispenner.ca/posts/wc
Edit: upon reading the article it seems like the'yre different kinds of word counting. Still interesting and worth reading nevertheless!