fsprojects / FSharp.Data.Adaptive

On-demand adaptive/incremental data for F# https://fsprojects.github.io/FSharp.Data.Adaptive/
MIT License
250 stars 24 forks source link

IHashSetReader, IHashMapReader, IIndexListReader not exposed to C# #66

Closed luithefirst closed 3 years ago

luithefirst commented 4 years ago

Accessing GetReader from C# has IOpReade<...> as return type. This forces writing very long type names e.g when used as class members or method arguments.

ChangeableIndexList<MySuperLongTypename> myList = new ChangeableIndexList<MySuperLongTypename>();
IOpReader<IndexList<MySuperLongTypename>, IndexListDelta<MySuperLongTypename>> myReader = myList.GetReader();

It would be nice to avoid type abbreviations if possible.

krauthaufen commented 4 years ago

Hey, I see the issue there but sadly I can't think of a way to solve this without introducing significant overhead.

The obvious way would be to introduce something like:

type IHashSetReader<'T> =
    inherit IOpReader<CountingHashSet<'T>, HashSetDelta<'T>>

The problem here is that all the aset/alist/etc. readers are created by the generic History which cannot know which specific reader to create and how to do it.

The only other option I can think of is to wrap all readers created by History effectively doubling the number of readers everywhere and obfuscating large parts of the implementation due to constantly wrapping/unwrapping readers.

It's quite ridiculous that C# doesn't have type aliases. (apart from the ones that are built-in like int, string, etc.)

you could prefix all files with things like

using ISetReaderInt = FSharp.Data.Traceable.IOpReader<FSharp.Data.Traceable.CountingHashSet<int>, FSharp.Data.Adaptive.FSharpHashSetDelta<int>>;

which seems to be incapable of handling generic arguments...

krauthaufen commented 3 years ago

can't think of a way here...