-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
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
NothingThis is peculiar in several ways:
-
You cannot use
(ix “foo”)to insert a new value into aMap:> set (ix "foo") "bar" Map.empty (fromFoldable [])
… and yet you can with a
Set. -
I’m not sure what form the
set-getoptics law should take withixoptics. But you can’t get what you can set, which seems odd. Actually, as far as I can tell, you can’tvieworpreviewanything in aSet:> preview (ix "foo") (Set.singleton "foo") Nothing > view (ix "foo") (Set.singleton "foo") unit
Is the instance for Set a well-behaved optic? Should it be?
Metadata
Metadata
Assignees
Labels
No labels