-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The ^=
operator seems backwards, and I'm not sure about the ^%
operator
#47
Comments
Yes, I do want to revisit these, because they do feel a bit off. For 9.0 I'm definitely open to them being re-ordered. I think what I'll do is a advertise the possibility in the Gitter channel as well and see if there's any strong objections, but otherwise pencil it in for a 9.0 release, possibly some time soon. |
Deleted past comment. Me being dumb while learning the library and F# at the same time. I agree with the OP, would feel more natural with them reversed |
Edit: Useless suggestion removed. |
varon, you might have missed that there are some operators So you can do
The issue was the order of set ^= If you look at the original post you will see in action |
@WozSoftware - Yeah, I actually use those extensively, but apparently I was completely mistaken about the actual source of the braces requirements. The elimination of braces is still something I want to do, but that post literally has nothing to do with it, so I've removed it. At the moment, we have mandatory braces required due to the lower precedence of the lens and prism composition operators type BarRecord = { StringField: string }
type FooRecord = { Bar: BarRecord }
let bar_:Lens<_,_> = (fun x -> x.Bar), (fun v x -> { x with Bar = v } )
let stringField_:Lens<_,_> =(fun x -> x.StringField), (fun v x -> { x with StringField = v } )
let data = { Bar = { StringField = "test" } }
//Given the current operators, this line requires braces around the lens composition.
let wontCompile = data |> "some string" ^= bar_ >-> stringField_
let willCompile = data |> "some string" ^= (bar_ >-> stringField_) Whereas if we defined the composition operator starting with the let inline (+>>) l o = Compose.lens l o
let noBracesNeeded = data |> "some string" ^= bar_ +>> stringField_ I went with I do think that if we remove the braces around the compose lenses, then flipping the operator order for let simplest = data |> bar_ +>> stringField_ ^= "some string" |
With
Optic.set
, the parameters are in the order I would expect. But the^=
operator has the parameters backwards fromOptic.set
, which is not what I would expect. As forOptic.map
and the^%
operator, I'm not 100% sure which way around I'd expect the parameters to be, but I feel like they should at least be consistent between^%
andOptic.map
. Let me use an example to show you what I mean:It's probably too late to change this for Aether 8.x, but 9.x isn't released yet, right? At least I don't see a NuGet package for 9.0. I'd love to see the
^=
operator feel a bit more natural to use (even if it won't ever be really natural -- it "wants" to be a custom ternary operator, and F# makes it hard to define those).The text was updated successfully, but these errors were encountered: