Skip to content
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

importing Focus and Swiftz cause operators such as ||| to fail to compile #40

Open
BrianDoig opened this issue Oct 31, 2017 · 4 comments

Comments

@BrianDoig
Copy link

import Swiftz 
import Focus

func fanin<A, B, C>(_ l: @escaping (A) -> C, _ r: @escaping (B) -> C) -> Function<Either<A, B>, C> {
    return Function.arr(l) ||| Function.arr(r)
}

The above fails to compile and there doesn't seem to be a way to specify which library you want the operator to come from since Swiftz.||| fails to compile.

***: error: ambiguous operator declarations found for operator
return Function.arr(l) ||| Function.arr(r)
^
:0: note: found this matching operator declaration
:0: note: found this matching operator declaration
***: error: operator is not a known binary operator
return Function.arr(l) ||| Function.arr(r)

@CodaFi
Copy link
Member

CodaFi commented Oct 31, 2017

You're using git submodules or Carthage, no? SwiftPM should be able to resolve the dependency properly - or not, I remember it had some problems with top-of-tree dependencies. But it's nothing we can't fix by editing the package file.

@CodaFi
Copy link
Member

CodaFi commented Oct 31, 2017

If git submodules are a requirement, the correct answer is to write two different Swift files for code that needs Focus and code that needs Swiftz and use wrapper functions to bridge the gaps where necessary. A terrible problem to have, but one introduced by a source-breaking change in the proposal that "simplified operator declarations".

@BrianDoig
Copy link
Author

Unfortunately, it's either git submodules or CocoaPods that I have to use. Since CocoaPods doesn't work at the moment, I'm stuck with submodules. I ended up doing what you suggested. My above example was actually one of my wrapper functions to get around it.

It's not like it's uncommon for multiple libraries to declare their own operators and for there to be no way to resolve conflicts seems like a serious design flaw on the part of the Swift team.

@BrianDoig
Copy link
Author

Ended up getting approval to use Swift package manager so that took care of the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants