Last active
June 15, 2016 12:54
-
-
Save AlexanderNey/39845ee92e3b693a2145 to your computer and use it in GitHub Desktop.
ARTICLE Function Composing Swift 2.0 - 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infix operator >>> { precedence 50 associativity left } | |
public func >>> <A,B,C>(left: A throws -> B, right: B throws -> C) -> (A throws -> C) { | |
return { (parameter: A) throws -> C in | |
return try right(left(parameter)) | |
} | |
} | |
let data = ... | |
let handleResponse = parseJSONFromNSData >>> validateJSONResponse >>> unmarshalJSON(Model.self) | |
let model = try handleResponse(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment