plato
plato copied to clipboard
ISequence<T> vs IGenerator<T>
If every ISequence<T> has a generator, and IGenerator<T> extends ISequence<T> why are they two separate types? This seems like a distinction that doesn't make a difference as ISequence<T> has nothing else.
I've arrived at a similar conclusion recently. Going to push an update real soon based on some concrete implementations, which does leave them distinct.
In case you are interested I got to that design point through the following observations:
- Every sequence has a generator, which is sufficient to implement the entire LINQ library
- Every sequence can be adapted into a generator (iter.HasValue => seq.Any(), iter.Value => seq.First(), iter.Next => seq.Skip(1)
- Every generator can be adapted into a sequence, by (seq.Generator() => this)
- Every LINQ operation that can be defined on sequences, could also be defined on generators (Select/Where/Aggregate/etc.)
I'll share soon the new version soon.