Hacker News new | ask | show | jobs
by involans 2760 days ago
It is useful to be able to speak of Lens and Traversal to distinguish intent. All lenses are Traversals, but not vice versa. What you have here is of course the Traversal system without the other optics.
1 comments

It's also useful for stuff like 'get' to look differently.

    user ^. id
    txt ^? _JSON . key "foo"
    txt ^?! _JSON . key "foo"
First one gives exactly one result. The second one is the equivalent of returning null on failure. The third one throws an exception on failure.

And because of the somewhat peculiar implementation of van laarhoven lenses we get subtyping so it doesn't get in the way.