Hello all,
I have a small swatch editor with a three-case palette union. A fresh edit is NotEntered, a deliberate clear is Empty, and Colors holds a list. I made the cases private and exposed only ofColors, where ofColors [] gives Empty. My expectation was that the compiler would make Colors [] impossible to build.
In a scripted session (fresh, add blue, remove blue, Save), Save prints "0 colors" instead of "empty (chosen)". Reset behaves correctly. Rider shows no squiggle and the build is clean.
I suspected List.filter first, then Rider using a different SDK than global.json, so I rebuilt from the terminal. The result was the same.
This is the function I think is responsible:
let remove (name: string) (p: Palette) =
match p with
| Colors cs -> Colors(cs |> List.filter (fun c -> c.Name <> name))
| other -> other
Is the privacy only checked outside Palette.fs, so my own module can build Colors [] freely? The access control page seems to suggest so, but I am not certain. If so, is routing add and remove through ofColors the normal fix, or is the type itself wrong? I am also wondering whether a plain list plus an entered flag would be simpler here.
Thank you, Oskar