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
Better error messages #402
Better error messages #402
Conversation
c3dee31
to
ebdd1d7
Compare
OK, ready for review. There are many more warnings around |
} yield res | ||
) | ||
.orRefine({ case ref: Schema[_] if Option(ref.get$ref).isDefined => ref })(ref => getSimpleRef(ref.get).map(Deferred[L])) | ||
.orRefine({ case b: BooleanSchema => b })(buildResolve(litBoolean)) |
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.
Turns out these were all the same, with only two variants (has default vs no default possible)
8e4745a
to
cdb3718
Compare
(" " * indent) + value.toString().linesIterator.filterNot(_.contains(": null")).mkString("\n" + (" " * indent)) | ||
} | ||
|
||
class RichCollection[A, Repr](xs: IterableLike[A, Repr]) { |
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.
from https://stackoverflow.com/a/3912833. distinctBy
is a member of 2.13's View
, so this can go away when we upgrade.
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.
This looks mostly fine to me. I don't really understand some or it, like IndexedDistributive
, but I appreciate that there are new tests around this, and all the old tests still pass.
implicit class OptionSyntax[A](tracker: Tracker[Option[A]]) { | ||
def orHistory: Either[Vector[String], Tracker[A]] = tracker.indexedCosequence.toRight(tracker.history) | ||
def raiseErrorIfEmpty(err: String): Target[Tracker[A]] = Target.fromOption(tracker.indexedCosequence, s"${err} (${tracker.showHistory})") | ||
class FlatDownFieldPartiallyApplied[C](val dummy: Boolean = true) { |
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.
extends AnyVal
? (Otherwise, why bother with dummy
?)
(& other examples of the same in this file)
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.
This follows the pattern used in cats to partially apply type arguments. dummy
is presumably required to avoid syntactic ambiguity, but the big thing is by fixing C
in the call site, it permits:
t.downField[Int]("foo", _.getFoo)
instead of t.downField[Option[Int], Int]("foo", _.getFoo)
Small improvement in ergonomics for the user, as it frees the unspecified type parameter to be resolved by the compiler.
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.
Yeah, I've seen that pattern cats, but they do extends AnyVal
on those. I assumed the need for dummy
was just because you have to have one-and-only-one val
constructor param when extending AnyVal
.
modules/codegen/src/main/scala/com/twilio/guardrail/generators/syntax/package.scala
Show resolved
Hide resolved
To follow up on "I don't really understand some of it, like given I think the name comes from the distributive property of arithmetic: The other side of the name, Initially I actually didn't have this abstraction, and I ended up writing almost identical syntax extensions for all the different structures I was trying to represent. There was a lot of duplication and divergent method names, since I wasn't sure what I had already implemented. When I started unifying them under this new banner of |
…syntax extensions
…Cosequence exists
f02675a
to
f23cbf7
Compare
Rebased! |
Welp, I don't really understand the stuff in that hackage link, but your description helped a lot, thanks! |
Problem:
Missing operationId
is not a useful error message, especially with particularly large specification files.--
Given:
the following will compile:
there are a number of combinators borne of necessity, though my intent that it should be possible to writeTraverse
andMonoid
instances for these structures, which may simplify syntax a bit.I've broken out
IndexedFunctor
andIndexedDistributive
, as well as some syntax around these combinators, but that permitted a significant reduction in bespoke syntax extensions.The intent of opening this PR is to get feedback on this approach, as well as to publicize the fact that this is coming, in case others plan on doing major refactors.
Contributing to Twilio