Skip to content
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

add id hints onto more generated types #36

Merged
merged 9 commits into from
Jan 13, 2022
Merged

add id hints onto more generated types #36

merged 9 commits into from
Jan 13, 2022

Conversation

lewisjkl
Copy link
Contributor

This is an attempt to close #35. There are a few areas I am unsure of (will add comments below inline). Additionally, I wasn't sure if we want to be adding the hints onto primitive types within structures and such. Thoughts?

@@ -517,7 +521,7 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self =>
newline,
line(s"def to(e: $name) : (String, Int) = (e.value, e.ordinal)"),
lines(
s"val schema: $Schema_[$name] = enumeration(to, valueMap, ordinalMap)",
s"val schema: $Schema_[$name] = (enumeration(to, valueMap, ordinalMap): $Schema_[$name]).withHints(hints)",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't compile without the type hint here, not sure of another way around this atm

Comment on lines +11 to 12
val underlyingSchema : smithy4s.Schema[String] = string.withHints(hints)
val schema : smithy4s.Schema[BucketName] = bijection(underlyingSchema, BucketName(_), (_ : BucketName).value)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't sure if this was correct or not to have the hints on underlyingSchema.. I am thinking they should actually be on the schema following the bijection?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think on the whole thing, yeah (not underlyingSchema)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It shouldn't make a difference :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually,@kubukoz is correct. On the schema, we have a chance of writing interpreters that retain the information of the id of the underlying schema;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually maybe not. I think it's fine as it is : the hints should be applied on the "underlyingSchema". That is because we do not use the newtypes for collections, except when they are used as hints themselves. However, we still want the underlying schema of collections to contain the hints.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We should really have some smoke tests for this kind of thing 😓 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought to have this on the big thing so that the implementation of the Schematic would carry it over to the wrapped schema in a Hinted or something

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought to have this on the big thing so that the implementation of the Schematic would carry it over to the wrapped schema in a Hinted or something

Yeah, that is not incorrect, but having it on the small thing makes more sense, because otherwise you wouldn't have the id for collection shapes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I see now

@lewisjkl lewisjkl requested a review from Baccata January 10, 2022 23:58
@@ -480,7 +480,9 @@ private[codegen] class Renderer(compilationUnit: CompilationUnit) { self =>
s"case c : $caseName => $caseName.alt(c)"
}
}
.appendToLast(if (hints.nonEmpty) ".withHints(hints)" else "")
.appendToLast(
if (error) "" else ".withHints(hints)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errors are not an actual union in smithy, so they shouldn't really receive hints

@@ -39,12 +39,12 @@ object enumeration {
}

trait Syntax {
def enumeration[H, S[x[_]] <: Schematic[x], A](
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was un-necessary, and preventing type inference from working properly

with errorUnion.Syntax {

val short: Schema[Short] =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the changes bellow should address the concern of not having shape ids for primitive types

@Baccata Baccata marked this pull request as ready for review January 13, 2022 14:01
@kubukoz kubukoz merged commit 38d51ec into main Jan 13, 2022
@kubukoz kubukoz deleted the issue-35 branch January 13, 2022 14:33
Baccata pushed a commit that referenced this pull request May 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Struct/union name hints
3 participants