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

Hide the constructors and raw record fields of message types. #174

Merged
merged 4 commits into from
Aug 26, 2018

Conversation

judah
Copy link
Collaborator

@judah judah commented Jan 30, 2018

They're not that useful for constructing values (especially after adding the
"unknown fields" case) and were previously mostly used for documentation. Now
that #172 has landed, we have a better source of documentation that doesn't
expose internal details.

Also change the Show instance for messages to be a wrapper around
showMessageShort. This both hides the now-inaccessible record fields and
shortens the output in most cases. For example:

> print (def :: DescriptorProto)
{}
> print (def & #name .~ "hello" & #field .~ [def, def & #name .~ "bye"]:: DescriptorProto)
{name: "hello" field { } field { name: "bye" }}

Also bump the resolver for bootstrapping to match the regular build.

Hide message constructors.

showsPrec, and bootstrap


This change is Reviewable

They're not that useful for constructing values (especially after adding the
"unknown fields" case) and were previously mostly used for documentation.  Now
that google#172 has landed, we have a better source of documentation that doesn't
expose internal details.

Also change the `Show` instance for messages to be a wrapper around
`showMessageShort`.  This both hides the now-inaccessible record fields and
shortens the output in most cases.  For example:

```
> print (def :: DescriptorProto)
{}
> print (def & #name .~ "hello" & #field .~ [def, def & #name .~ "bye"]:: DescriptorProto)
{name: "hello" field { } field { name: "bye" }}
```

Also bump the resolver for bootstrapping to match the regular build.

Hide message constructors.

showsPrec, and bootstrap
@@ -1,4 +1,4 @@
resolver: lts-9.21
resolver: lts-10.3
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this foreclose any bootstrap options?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not really; as long as we keep testing the older LTS's in TravisCI, we'll be reasonable sure it's possible to bootstrap with older versions by manually editing this file. I think it's just more convenient for developers if this is in sync with stack.yaml.

@judah
Copy link
Collaborator Author

judah commented Jan 31, 2018

Unfortunately this causes problems related to #167; since the types don't have exposed constructors, users can't derive their own instances for them.

For example: https://travis-ci.org/google/proto-lens/jobs/335018254

Leaving open for now while I try to think of a workaround.

@judah judah merged commit 4a97752 into google:master Aug 26, 2018
@judah judah deleted the hide-constructor branch August 26, 2018 18:17
avdv pushed a commit to avdv/proto-lens that referenced this pull request Aug 9, 2023
…#174)

Finishes google#158.

They're not that useful for constructing values (especially after adding the
"unknown fields" case) and were previously mostly used for documentation.  Now
that google#172 has landed, we have a better source of documentation that doesn't
expose internal details.

Also change the `Show` instance for messages to be a wrapper around
`showMessageShort`.  This both hides the now-inaccessible record fields and
shortens the output in most cases.  For example:

```
> print (def :: DescriptorProto)
{}
> print (def & #name .~ "hello" & #field .~ [def, def & #name .~ "bye"]:: DescriptorProto)
{name: "hello" field { } field { name: "bye" }}
```

Also bump the resolver for bootstrapping to match the regular build.
ylecornec pushed a commit to ylecornec/proto-lens that referenced this pull request Feb 19, 2024
…#174)

Finishes google#158.

They're not that useful for constructing values (especially after adding the
"unknown fields" case) and were previously mostly used for documentation.  Now
that google#172 has landed, we have a better source of documentation that doesn't
expose internal details.

Also change the `Show` instance for messages to be a wrapper around
`showMessageShort`.  This both hides the now-inaccessible record fields and
shortens the output in most cases.  For example:

```
> print (def :: DescriptorProto)
{}
> print (def & #name .~ "hello" & #field .~ [def, def & #name .~ "bye"]:: DescriptorProto)
{name: "hello" field { } field { name: "bye" }}
```

Also bump the resolver for bootstrapping to match the regular build.
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.

None yet

2 participants