<*> operator

The <*> operator is used to conditionally apply the other parameters to our curried init method. The definition is as follows:

public func <*> <T, U>(f: Decoded<(T) -> U>, x: Decoded<T>) -> Decoded<U> { 
return x.apply(f)
}

func apply<U>(_ f: Decoded<(T) -> U>) -> Decoded<U> {
switch (f, self) {
case let (.success(function), _): return self.map(function)
case let (.failure(le), .failure(re)): return .failure(le + re)
case let (.failure(f), _): return .failure(f)
}
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset