
Usable discriminated union in C#: one-line typed, Equality, ToString included - dadhi
https://gist.github.com/dadhi/815cf2ef8e88b555c59be7e4be93e712
======
dlahoda
I was able to code like next

// merge update into immutable (each mutation gives new handle)

private void MergeIntoImmutableThreadAffinedObject(Updates.ICase update)

{

    
    
                switch (update)
                {
                    case ICase<ImmutableTimeSeriesFilesDatabase> c:
                        _updater.Update(x => x.Set(RefCountedHandle, c.Value));
                        return;
    
                    case ICase<ImmutableObjectDatabase> m:
                        _updater.Update(x => x.Set(Configuration, m.Value));
                        return;
    
                    case ICase<ITimeSeriesFilterSort> f:
                        _updater.Update(x => x.Set(SearchFilterSort, f.Value));
                        return;
    
                    case ICase<IApplicationFilters> a:
                        _updater.Update(x => x.Set(ApplicationFilters, a.Value));
                        return;
    
                    default: throw new NotSupportedException();
                }
            }
    }

~~~
dlahoda
internal sealed class Updates : Union<Updates,
ImmutableTimeSeriesFilesDatabase, ImmutableObjectDatabase,
ITimeSeriesFilterSort, IApplicationFilters> { }

