             return indices
         }
 
-        func insertionsPatch(_ indices: [UnderlyingCollection.Index]) -> [UnderlyingCollection.Index] {
+        func insertionsPatch(_ indices: [Index]) -> [Index] {
             var indices = indices
             for i in 0..<indices.count {
                 let pivot = indices[i]

}

// swiftlint:disable:next function_body_length
func generateDiff<UnderlyingCollection: Collection>(from sequenceOfChanges: [ObservableCollectionChange<UnderlyingCollection>], in list: UnderlyingCollection) -> [ObservableCollectionChange<UnderlyingCollection>] {
    var diff = sequenceOfChanges.flatMap { $0.unwrap(using: list) }

    for i in 0..<diff.count {

import Differ
import ReactiveKit

public enum ObservableCollectionChange<Index: Equatable>: Equatable {
    case reset
    case inserts([Index])
    case deletes([Index])
    case updates([Index])
    case move(Index, Index)
    case beginBatchEditing
    case endBatchEditing
}

public protocol ObservableCollectionEventProtocol {
    associatedtype UnderlyingCollection: Collection

    var change: ObservableCollectionChange<UnderlyingCollection.Index> { get }
    var source: UnderlyingCollection { get }
}

public struct ObservableCollectionEvent<UnderlyingCollection: Collection>: ObservableCollectionEventProtocol {
    public let change: ObservableCollectionChange<UnderlyingCollection.Index>
    public let source: UnderlyingCollection

    public init(change: ObservableCollectionChange<UnderlyingCollection.Index>, source: UnderlyingCollection) {
        self.change = change
        self.source = source
    }
}

public struct ObservableCollectionPatchEvent<UnderlyingCollection: Collection>: ObservableCollectionEventProtocol {
    public let change: ObservableCollectionChange<UnderlyingCollection.Index>
    public let source: UnderlyingCollection

    public init(change: ObservableCollectionChange<UnderlyingCollection.Index>, source: UnderlyingCollection) {
        self.change = change
        self.source = source
    }
}

public class ObservableCollection<UnderlyingCollection: Collection>: SignalProtocol {
    public fileprivate(set) var collection: UnderlyingCollection
    public let subject = PublishSubject<ObservableCollectionEvent<UnderlyingCollection>, NoError>()
    public let lock = NSRecursiveLock(name: "com.reactivekit.bond.observable-collection")
