Replies: 3 comments 3 replies
-
|
I far prefer |
Beta Was this translation helpful? Give feedback.
-
|
Also in favor of |
Beta Was this translation helpful? Give feedback.
-
|
I wonder if there's some confusion based on the comments. Just to clarify, we're talking about these operators here: whereExists :: Query a -> Query ()
whereNotExists :: Query a -> Query ()Not this operator here: exists :: Query a -> Query (Expr Bool)
semijoin :: Query a -> Query b -> Query a
semijoin a b = a *> present bantijoin :: Query a -> Query b -> Query a
antijoin a b = a *> absent b |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
@shane-circuithub proposes that we rename
whereExiststopresent, andwhereExiststowhereNotExists(#57). This will ultimately be a breaking change (though we would likely deprecate the existing functions and gradually remove), but we're not able to reach an agreement as to whether or not we should do this. We'd love to hear feedback to help us make a decision!Proposal: Rename
whereExiststopresentandwhereNotExiststoabsent.Argument for: I think the names
whereExistsand particularlywhereNotExistsare fairly unwieldy for something that corresponds to such a nice algebraic operation in the underlying relational algebra, i.e., semijoins and antijoins respectively. If they weren't just literal translations of the SQL they generate, I don't think we would have ever chosen those names for a Haskell combinator. I think it's important to have short, concise names for foundational algebraic combinators, because it leaves room for other people to come along and define variations of them with prefixes and suffixes. This is the pattern throughout most ofRel8, withoptional,many, and our heavy reliance on monadic composition of queries. I don't think the nameswhereExistsandwhereNotExistsdo their combinators justice. Even if users may not be familiar withpresentandabsentat first glance, the names do capture both what they do and their relation to each other, and I think this precision and their conciseness will allow them to be quickly internalised by users.Argument against: I think
whereExistsandwhereNotExistsappeal to intuition, assuming the user is familiar with SQL. If I'm reading Rel8 code, I can have an idea whatwhereExistswill do, whilepresentis unfamiliar, both in SQL and Haskell (as far as I'm aware).presentis ambiguous in isolation (though unambiguous when paired withabsent), and I worry people may interpretpresentas "presenting" aQuery, rather than checking for the presence of rows.Alternatives:
presentandabsent, leavingwhereExistsandwhereNotExistsunchanged (and not deprecated).Beta Was this translation helpful? Give feedback.
All reactions