Re:Programming languages should have a tree traversal primitive
by bts on Tuesday April 29, 2025 @10:39AM
(#43833317)
Agreed; also Traversable in Haskell is a simpler abstraction than lenses and pretty directly addresses what they seem to be looking for: https://hackage.haskell.org/package/base-4.21.0.0/docs/Data-...
[ Parent
| on HN ]
Re:Programming languages should have a tree traversal primitive
by chowells on Tuesday April 29, 2025 @01:25PM
(#43835505)
Traversable and lenses are very closely linked. If you go to the original paper leading to Traversable [1] and read through it, it feels basically identical to reading through the parts of the lens library that lay down the core abstractions and the laws implementations must follow if you want to be able to blindly manipulate them. In fact, the traverse function is a Traversal, and so fits trivially into the lens ecosystem.
[1] https://www.cs.ox.ac.uk/jeremy.gibbons/publications/iterator...
Re:Programming languages should have a tree traversal primitive
by Akronymus on Wednesday April 30, 2025 @09:05AM
(#43844677)
Arent haskell traversables different in that they preserve the structure if you were to map over them, as compared to the solution posted in the article, where they get flattened to what amounts to a list?