You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
profunctor-lenses has the ix function to produce 0-or-1 (“affine”) Traversals. It’s nice for arrays and maps. I noticed it also has an instance for Set. Fooling around, I saw the following:
> result = set (ix "foo") unit Set.empty
> result
(fromFoldable ("foo":Nil))> preview (ix "foo") result
Nothing
This is peculiar in several ways:
You cannot use (ix “foo”) to insert a new value into a Map:
> set (ix "foo")"bar"Map.empty
(fromFoldable [])
… and yet you can with a Set.
I’m not sure what form the set-get optics law should take with ix optics. But you can’t get what you can set, which seems odd. Actually, as far as I can tell, you can’t view or preview anything in a Set:
profunctor-lenses
has theix
function to produce 0-or-1 (“affine”)Traversals
. It’s nice for arrays and maps. I noticed it also has an instance forSet
. Fooling around, I saw the following:This is peculiar in several ways:
You cannot use
(ix “foo”)
to insert a new value into aMap
:… and yet you can with a
Set
.I’m not sure what form the
set-get
optics law should take withix
optics. But you can’t get what you can set, which seems odd. Actually, as far as I can tell, you can’tview
orpreview
anything in aSet
:Is the instance for
Set
a well-behaved optic? Should it be?The text was updated successfully, but these errors were encountered: