-
Notifications
You must be signed in to change notification settings - Fork 1
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
Multiquery #28
Multiquery #28
Conversation
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.
There are two instances in tests where you still have a non empty list inside a multiquery, but I don't think that necessary?
Otherwise this is awesome!! Excited for mapLast
def mapLast(f: Query => Query): MultiQuery = | ||
if (qs.size == 1) MultiQuery(NonEmptyList.one(f(qs.head))) | ||
else { | ||
val newT = qs.tail.init :+ f(qs.last) |
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 always forget about init
, nice
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 don't really understand the naming, but yeah, it's handy.
Sucks that changing the last element is so expensive though.
def assertSingleTerm(r: Either[Error, MultiQuery], expected: Query)(implicit | ||
loc: munit.Location | ||
) = | ||
assertEquals(r, Right(MultiQuery(NonEmptyList.one(expected)))) |
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.
Do you still need the non empty list here? Can't you just pass expected
as the head
to MultiQuery?
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.
Nice catch
loc: munit.Location | ||
) = | ||
assertEquals(r, Right(NonEmptyList.one(expected))) | ||
assertEquals(r, Right(MultiQuery(NonEmptyList.one(expected)))) |
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.
Same question here
Adds a
MultiQuery
class that wraps aNonEmptyList[Query]
.It's main purpose is to change the parser return type from
Either[Error, NonEmptyList[Query]]
toEither[Error, MultiQuery]
and thus be one lessNonEmptyList
end users have to deal with. Additionally it serves a great place to hold themapLast
method.Closes #24