-
Notifications
You must be signed in to change notification settings - Fork 39
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
Should Rel8 functions be in a curry-friendly (haskell style) or infix-friendly (sql / operator style) argument order? #164
Comments
Here's our conversation when we chose this argument order: Shane: But I guess if we're calling it the same thing SQL calls it we might as well use SQL's order too Ollie: Shane: Ollie: Shane:
Are you sure? Ollie: Shane:
Ollie: I guess it's worth looking at usage. To take a concrete example, we have
Or
When you put the two next to each other, it kinda looks commutative anyway Shane: But I think Ollie: I'll make that change and a comment clarifying the order, and why we've chosen it |
I should also add I know the incident you're referring to, and I'm pretty sure that was me who caused the problem, not said colleague! We (CircuitHub) had our own |
Sorry yeah, it was a migration from older I think This seems like a similar familiarity trade-off as Elm's flipped |
(My main worry is that if we change this later everyone's queries will break silently like ours did) |
Perhaps a final bit of consideration I could add: It looks to me like postgresql functions may in general be more infix-friendly than curry-friendly. E.g.
string `starts_with` prefix as opposed to the more curry-friendly (starts_with prefix) string
string `repeat` int as opposed to the more curry-friendly
I think I'm generally more in favor of curry-friendly when writing haskell code from scratch, but perhaps worth considering whether we generally want to thinly wrap or generally want to reorder. I think either is probably ok, but probably good to make the decision explicitly. I'll rename the issue to reflect the broader question... |
The answer of course is rewrite GHC to flip the order of arguments when infixing. Sorry, not a useful contribution, but i couldn't help myself becuase always felt infixing functions should work that way. |
I saw a thing recently that suggested using |
This was discussed offline at some point, but I thought I'd just double-check that this is really what we want? The feature is still brand new so it seems worth getting it right.
A colleague made the mistake of assuming
ilike
takes arguments in the same order as postgresql defines. I can easily see myself doing the same and being confused about why the query result are "wrong". I hardly spend any time looking at documentation for something as simple and familiar aslike
.Taking two possible patterns for using
ilike
:and
Do we really lose much with the unflipped version?
and
The text was updated successfully, but these errors were encountered: