         }
     }
 
-    // Return a failure if we have one.
-    // Otherwise, transform the success value into a new success value.
+    /**
+     Transforms a success value and wraps it in a new successful result.
+
+     If the receiver is a failure, wraps the same error without invoking `transform`.
+
+     - parameter transform: A function that produces a new success value, given a success value.
+     - returns: A result with the transformed success value or the original failure.
+     */
     public func map<U>(_ transform: (Value) -> U) -> Result<U> {
         return tryMap(transform)
     }
 
-    // The canonical flatMap.
-    // Return a failure if we have one.
-    // Otherwise, transform the success value into a new success or failure.
+    /**
+     Transforms a success value into a new successful or failed result.
+
+     If the receiver is a failure, wraps the same error without invoking `transform`.
+
+     - parameter transform: A function that produces a new result, given a success value.
+     - returns: The transformed result or the original failure.
+     */
     public func flatMap<U>(_ transform: (Value) -> Result<U>) -> Result<U> {
         return tryMap { value in
             try transform(value).value()
         }
     }
 
-    // An error-catching variation on flatMap.
-    // Return a failure if we have one.
-    // Otherwise, transform the success value into a new success value, or fail if an error is thrown.
+    /**
+     Transforms a success value into a new successful or failed result.
+     
+     If the receiver is a failure, wraps the same error without invoking `transform`.
+
+     - parameter transform: A function that returns a new success value or throws a new error, given a success value.
+     - returns: The transformed result or the original failure.
+     
+     This is an error-catching variation on `flatMap(_:)`.
+     */
     public func tryMap<U>(_ transform: (Value) throws -> U) -> Result<U> {
         return Result<U> {
             try transform(try value())

        }
    }

    // Unwrap a success value or throw a failure value.
    public func value() throws -> Value {
        switch self {
        case .success(let value):


}

/**
 From two results, returns one result wrapping all their values or the first error.

 - parameter resultA: The first result to repackage.
 - parameter resultB: The second result to repackage.
 - returns: A result wrapping either a tuple of all the given results' success values, or the first error among them.
 */
public func zip<A, B>(_ resultA: Result<A>, _ resultB: Result<B>) -> Result<(A, B)> {
    return resultA.tryMap { a in
        (a, try resultB.value())
    }
}

/**
 From three results, returns one result wrapping all their values or the first error.
 
 - parameter resultA: The first result to repackage.
 - parameter resultB: The second result to repackage.
 - parameter resultC: The third result to repackage.
 - returns: A result wrapping either a tuple of all the given results' success values, or the first error among them.
 */
public func zip<A, B, C>(_ resultA: Result<A>, _ resultB: Result<B>, _ resultC: Result<C>) -> Result<(A, B, C)> {
    return zip(resultA, resultB).tryMap { a, b in
        (a, b, try resultC.value())
    }
}

/**
 From four results, returns one result wrapping all their values or the first error.
 
 - parameter resultA: The first result to repackage.
 - parameter resultB: The second result to repackage.
 - parameter resultC: The third result to repackage.
 - parameter resultD: The fourth result to repackage.
 - returns: A result wrapping either a tuple of all the given results' success values, or the first error among them.
 */
public func zip<A, B, C, D>(_ resultA: Result<A>, _ resultB: Result<B>, _ resultC: Result<C>, _ resultD: Result<D>) -> Result<(A, B, C, D)> {
    return zip(resultA, resultB, resultC).tryMap { a, b, c in
        (a, b, c, try resultD.value())
    }
}

/**
 From an array of results, returns one result wrapping all their values or the first error.
 
 - parameter results: The array of results to repackage.
 - returns: A result wrapping either an array of all the given results' success values, or the first error among them.
 */
public func zipArray<T>(_ results: [Result<T>]) -> Result<[T]> {
    return results.reduce(Result { [] }) { arrayResult, itemResult in
        arrayResult.tryMap { array in
