Hi,
Are there any plans of adding ID[A] composition syntax similar to Haskell (&) and Scalaz's |>?
It's usually helpful when used with lenses:
obj |>
someLens.set(Some("value")) |>
someOtherLens.set(Some("otherValue"))
I'm happy to raise a PR for this if you think it would be usesul.
Did you consider working around it using function composition? this is essentially
val f = someLens.set(Some("value")) andThen someOtherLens.set(Some("otherValue"))
f(obj)
I agree that Scala's way of handling functions here might require doing weird things like adding (_) to every composed function though. However, it might also be the case if we had |> (and last time I was doing that, it didn't really help).
Also, I think you can map on Id, so obj.map(f) should be the same as obj |> f (although the editor support will be terrible)
This syntax can be handy at times. One option to consider would be to add it to mouse. cc @benhutchison
It鈥檚 already in mouse!
Ah so it is. I don't think that the README is currently advertising it :)
@SimY4 in that case I'm going to go ahead and close this out and recommend using mouse to get this syntax. While it is generally handy, it's not tied to any type classes or data types in Cats.
Most helpful comment
Ah so it is. I don't think that the README is currently advertising it :)
@SimY4 in that case I'm going to go ahead and close this out and recommend using mouse to get this syntax. While it is generally handy, it's not tied to any type classes or data types in Cats.