Despite the modest gain, it is appropriate because the operators are so instantly recognisable -- it is not a surprising feature.
It may be similarly justifiable to provide overloads for common collection operators:
set"$foo.list" ::= element
set"$foo.list :::= list
set"$foo.coll" ++= coll
set"$foo.coll" :+= postElement
set"$foo.coll" +:= preElement
These can be annoyingly fiddly with ~= explicit functions.
How should it be implemented? The monocle Cons functionality could work with ::, but none of the others would. If we used the standard Scala CanBuildFrom implicit stuff, then it would have to be consistent, rather than one thing using a Monocle typeclass.
Can it work as expected with polymorphic STAB optics?
Needs more experimentation to decide whether it is possible, or worth it.
Currently, we have some mildly convenient syntax sugar for updating numeric values:
Which translate to
Despite the modest gain, it is appropriate because the operators are so instantly recognisable -- it is not a surprising feature.
It may be similarly justifiable to provide overloads for common collection operators:
These can be annoyingly fiddly with
~=
explicit functions.How should it be implemented? The monocle
Cons
functionality could work with::
, but none of the others would. If we used the standard Scala CanBuildFrom implicit stuff, then it would have to be consistent, rather than one thing using a Monocle typeclass.Can it work as expected with polymorphic STAB optics?
Needs more experimentation to decide whether it is possible, or worth it.