-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add update; fix ambiguity #39
Conversation
@@ -14,7 +14,7 @@ | |||
buildForAnalyzing = "YES"> | |||
<BuildableReference | |||
BuildableIdentifier = "primary" | |||
BlueprintIdentifier = "NT_8274405197546C7088976F7D3DDE8DF1" | |||
BlueprintIdentifier = "C986EA57938522DE23E8CA570CCC6C80" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated XcodeGen...
Sources/Overture/KeyPath.swift
Outdated
@@ -117,10 +118,11 @@ public func mprop<Root, Value>( | |||
/// - update: An update function for a given value. | |||
/// - Returns: A reference-mutable setter function. | |||
public func mver<Root, Value>( | |||
_ keyPath: ReferenceWritableKeyPath<Root, Value>, | |||
reference keyPath: ReferenceWritableKeyPath<Root, Value>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one overload of mver
from a reference to a reference causes ambiguity with the inout
version when using inline closures...
@@ -52,11 +52,28 @@ public func mver<S, A>( | |||
/// - setter: A reference-mutable setter function. | |||
/// - f: A mutable value transform function. | |||
/// - Returns: A reference-mutable root transform function. | |||
public func mver<S: AnyObject, A>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think trailing where
is preferred now...
Sources/Overture/With.swift
Outdated
@@ -18,8 +18,18 @@ public func with<A, B>(_ a: A, _ f: (A) throws -> B) rethrows -> B { | |||
/// - a: A mutable value. | |||
/// - f: An in-out function. | |||
/// - Note: This function is commonly seen in operator form as "pipe-forward", `|>`. | |||
public func with<A>(_ a: inout A, _ f: (inout A) throws -> Void) rethrows { | |||
try f(&a) | |||
public func update<A>(_ a: inout A, _ fs: ((inout A) -> Void)...) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with
is now just for (A, (A) -> B) -> B
.
Sources/Overture/With.swift
Outdated
@@ -43,7 +66,20 @@ public func with<A>(_ a: A, _ f: (inout A) throws -> Void) rethrows -> A { | |||
/// - Returns: The result of `f` applied to `a`. | |||
/// - Note: This function is commonly seen in operator form as "pipe-forward", `|>`. | |||
@discardableResult | |||
public func with<A: AnyObject>(_ a: A, _ f: (A) throws -> Void) rethrows -> A { | |||
try f(a) | |||
public func update<A: AnyObject>(reference a: A, _ fs: ((A) -> Void)...) -> A { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This overload is also for fixing ambiguity with the inout
version when using inline closures...
@mbrandonw Do you have a better idea for naming those reference overloads?
|
This should fix #30, though let's discuss naming...