-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Description
With Optic.set, the parameters are in the order I would expect. But the ^= operator has the parameters backwards from Optic.set, which is not what I would expect. As for Optic.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 ^% and Optic.map. Let me use an example to show you what I mean:
type Data = { items: int list; code: string }
let items_ : Lens<_,_> = (fun d -> d.items), (fun l d -> { d with items = l })
let data = { items = [1;2;3]; code = "foo" }
data |> Optic.get items_ // This feels "natural"
data ^. items_ // As does this
data |> Optic.set items_ [4;5;6] // As does this
data |> ([4;5;6] ^= items_ ) // But this feels wrong
data |> (items_ ^= [4;5;6]) // This would feel more natural
data |> Optic.map items_ (List.map (*2)) // Whereas this feels "backwards"...
data |> (List.map (*2) ^% items_) // ... and this feels "natural"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).
embix, WozSoftware, Angr1st, bruno-cadorette and LAJW
Metadata
Metadata
Assignees
Labels
No labels