Skip to content

Instantly share code, notes, and snippets.

@nomothetis
Created February 16, 2015 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomothetis/386e13e25a93cd242f28 to your computer and use it in GitHub Desktop.
Save nomothetis/386e13e25a93cd242f28 to your computer and use it in GitHub Desktop.
import Foundation
struct ConversationViewSnapshot : Diffable {
func diffWith(diffable: ConversationViewSnapshot) -> ConversationViewDiff {
return ConversationViewDiff.None
}
func applyDiff(diff: ConversationViewDiff) -> ConversationViewSnapshot {
return self
}
}
enum ConversationViewDiff : Diff {
typealias BaseType = ConversationViewSnapshot
case None
func mergeWithDiff(diff: ConversationViewDiff) -> ConversationViewDiff {
return .None
}
}
struct Conversation {
}
protocol Diff {
typealias BaseType
func mergeWithDiff(diff:Self) -> Self
}
protocol Diffable {
func diffWith<B: Diff where B.BaseType == Self>(diffable:Self) -> B
func applyDiff<B: Diff where B.BaseType == Self>(diff:B) -> Self
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment