T.Response: SimpleResultType, T.Response.Element == T.APIKitResponse>(request: T, URLSession: NSURLSession = defaultURLSession, handler: (Result<T.APIKitResponse, SlackError>) -> Void = {r in}) -> NSURLSessionDataTask? { func trampoline(handler: (Result<T.APIKitResponse, SlackError>) -> Void) (result: Result<T.Response, APIError>) { switch result { case .Success(let some): switch some.result { case .OK(let res): handler(.Success(res)) case .Error(let err): handler(.Failure(err)) } case .Failure(let error): handler(.Failure(.OtherError(error))) } } return sendRequest(request, URLSession: URLSession, handler: trampoline(handler)) } }