News for hackers. Stuff that matters.
Re:Functor and Monad in Swift by JSoto on Friday January 02, 2015 @03:45PM (#8828444)
Yeah, this is correct. This would be wrong:

    func map<U>(f: T -> U) -> Result<U> {
        switch self {
        case let .Value(value):
            return Result<U>.Value(Box(f(value.unbox)))
        case let .Error(error):
            // self is Result<T>, but the return type must be Result<U>
            return self
        }
    }

There are no comments on this comment yet.