From ca3f42cd8dfef4309defb3afc2b929e5c2a2243b Mon Sep 17 00:00:00 2001 From: Stephen Celis Date: Fri, 18 Jan 2019 12:33:24 -0500 Subject: [PATCH] Fix --- .../Contents.swift | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/0043-the-many-faces-of-flatmap-pt2/ManyFacesOfFlatMapPt2.playground/Contents.swift b/0043-the-many-faces-of-flatmap-pt2/ManyFacesOfFlatMapPt2.playground/Contents.swift index c6496136..a250757a 100644 --- a/0043-the-many-faces-of-flatmap-pt2/ManyFacesOfFlatMapPt2.playground/Contents.swift +++ b/0043-the-many-faces-of-flatmap-pt2/ManyFacesOfFlatMapPt2.playground/Contents.swift @@ -368,46 +368,3 @@ aDelayedInt // F = Validated // F = Func // F = Parallel - - - -// extension Sequence { -// public func flatMap(_ transform: (Element) throws -> ElementOfResult?) rethrows -> [ElementOfResult] -// } - -// flatMap: ((A) -> B?) -> ((F) -> F) - - -func fromThrowing(_ f: @escaping (A) throws -> B) -> (A) -> Result { - return { a in - do { - return .success(try f(a)) - } catch let error { - return .failure(error) - } - } -} -func toThrowing(_ f: @escaping (A) -> Result) -> ((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(_ f: (A) -> Result) -> Result { - fatalError("Unimplemented") - } -} - - -extension Result { - func flatMap(_ f: (A) -> Result, Swift.Error>) -> Result { - fatalError("Unimplemented") - } -}