Open sharplet opened 9 years ago
Ok, so here's what happens when you have conflicting operator declarations:
/Users/adsharp/src/sharplet/State/CoreTests/CoreTests.swift:12:24: error: ambiguous operator declarations found for operator
let three = 2 |> add(1)
^
<unknown>:0: note: found this matching operator declaration
<unknown>:0: note: found this matching operator declaration
It's interesting that the compiler doesn't actually give a valid location the declarations it found.
So here's what I'd really like: by default, if you import State
, you should get everything, including the operators. But if you end up with a conflict because of another library you're using, you should be able to import State.Core
to get everything but the operators.
See #4 and #6 for specific use cases (but mainly #4).
For example, what happens if another framework defines
infix operator |> {}
, but with conflicting associativity or precedence, and then I import both in the same file? I've defined everything as methods for now, and I think custom operators should mostly just be sugar for those methods where it makes sense and clearly adds benefits to readability/understandability.Here's some options I can think of:
import State.Operators
? (Hopefully that's even a thing, right?) That would give users an option for conflict resolution, but if I'm going to have operators they should be there for good reason anyway, so is burying them in a different module/extension worth the loss of discoverability?State
type?