Skip to content

Instantly share code, notes, and snippets.

@cfr
Last active August 29, 2015 14:23
Show Gist options
  • Save cfr/10369b9cd5ceeb4a2ee9 to your computer and use it in GitHub Desktop.
Save cfr/10369b9cd5ceeb4a2ee9 to your computer and use it in GitHub Desktop.
Completion type instead of (a → Void)
struct Completion<A> {
let f: (A -> Void)
init(f: A -> Void) {
self.f = f
}
func run(a: A) {
f(a)
}
}
func proc(completion: (Either<NSError, Int> -> Void)) {
completion(Either(right: 0))
}
func proc(c: Completion(Either<NSError, Int>)) {
c.run(Either(right: 0))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment