-
Notifications
You must be signed in to change notification settings - Fork 98
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
Contract (and maybe Label) type #2167
Comments
One issue with adding built-in types, even without using them in the stdlib, is indeed backward compatibility: if we add those types as new keywords, then anyone who wrote It also means that now anyone who uses In general, when adding a new type, we need to answer the following questions:
All in all, it would be a step in the right direction and align well with the rest of the Nickel philosophy IMHO but wasn't implemented from the start because of the several design questions mentioned above, though none of which is a hard blocker. I wonder if that should be a 2.0 feature. |
I had a try at refactoring json-schema-to-nickel's contract library as combinators on eager contracts (as opposed to passing around functions and turning them into contracts at the end). It works ok, but the static typing experience is somewhat worse than the current situation: we don't have types for contracts or labels and so almost everything just ends up having the type
Dyn -> Dyn -> Dyn
.What if we built-in an opaque
Contract
type? Then you could haveany_of: [Contract] -> Contract
? Also, having aLabel
type would allowstd.contract.custom: (Label -> Dyn -> [| ... |]) -> Contract
which I think is nicer than the current situation.Backwards compatibility is one possible problem with this suggestion; I'm not sure that the standard library could be updated like I suggested above.
The text was updated successfully, but these errors were encountered: