Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jan 18, 2019
1 parent a251f24 commit ca3f42c
Showing 1 changed file with 0 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,46 +368,3 @@ aDelayedInt
// F<A> = Validated<A, E>
// F<A> = Func<A0, A>
// F<A> = Parallel<A>



// extension Sequence {
// public func flatMap<ElementOfResult>(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult]
// }

// flatMap: ((A) -> B?) -> ((F<A>) -> F<B>)


func fromThrowing<A, B>(_ f: @escaping (A) throws -> B) -> (A) -> Result<B, Swift.Error> {
return { a in
do {
return .success(try f(a))
} catch let error {
return .failure(error)
}
}
}
func toThrowing<A, B>(_ f: @escaping (A) -> Result<B, Swift.Error>) -> ((A) throws -> B) {
return { a in
switch f(a) {
case let .success(value):
return value
case let .failure(error):
throw error
}
}
}


extension Result {
func map<B>(_ f: (A) -> Result<B, Swift.Error>) -> Result<B, Swift.Error> {
fatalError("Unimplemented")
}
}


extension Result {
func flatMap<B>(_ f: (A) -> Result<Result<B, E>, Swift.Error>) -> Result<B, Swift.Error> {
fatalError("Unimplemented")
}
}

0 comments on commit ca3f42c

Please sign in to comment.