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

Feature request: const definitions for all builtin types #2

Open
TanklesXL opened this issue Mar 2, 2024 · 3 comments
Open

Feature request: const definitions for all builtin types #2

TanklesXL opened this issue Mar 2, 2024 · 3 comments

Comments

@TanklesXL
Copy link

When using this package I find myself wanting to check that functions accept/return certain types.

It makes sense to define them myself for custom types, but it would be great to have gleams primitive types represented as constants in this lib!

@lpil
Copy link
Member

lpil commented Mar 7, 2024

Could you share a bit of the motivation here? I would have though pattern matching would be sufficient here

@TanklesXL
Copy link
Author

TanklesXL commented Mar 7, 2024

in this case i'm trying to assert that a function has 1 parameter that is a String, i'd rather not have to dig into the implementation details to make my own version of the builtin-types every time i need to compare something with them.

the issue for me as a user of the package is that I have no way of knowing the expected shape of the gleam builtin types without already having seen the json and decoded it to know what they should look like

@lpil
Copy link
Member

lpil commented Mar 8, 2024

There's no implementation details here, this data structure is a public API, and checking the Hex documentation it does describe the shape of prelude types.

They could still be useful perhaps, though I'm not sure the use cases. Could you share what you code might look like with and without them?

One thing that seems like a limitation for me is that list and result can't be used in guards as they are functions.

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 a pull request may close this issue.

2 participants