-
Notifications
You must be signed in to change notification settings - Fork 0
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
RFC: Host types for dentaku #14
Conversation
For reviewers, please look at the last two commits only - the rest are from dependencies of this branch. |
|
Explicitly registering them is a good idea. |
The use-case is to allow us to have dentaku functions (in |
and report only at the very end in an ErrorSet. this patch causes the checker to continue trying to typecheck after it has found an unbound identifier (one where the type resolver returns nil). this means we can still find type errors and other unbound identifiers and report a more comprehensive and useful error at the end of the check.
in the #ast_nodes method
338f4ac
to
9d6fa8a
Compare
After a conversation with @joshuabates, I think we're happy with having everything declared. This can also be used internally to Dentaku for its basic types like Dentaku::Type.declare(:string) # within Dentaku
Dentaku::Type.declare(:'use-code') # for all our bespoke OC types, incl. :zoning, :address, etc
Dentaku::Type.declare(:list, 1) # one type argument indicating the type of value in the list
Dentaku::Type.declare(:dict, 1) # similar to the above - a dict with arbitrary keys but one type of value |
Closing as superseded by #20 |
The Problem
We currently have a good deal of dentaku code that deals with functions or complicated dictionaries, whose values are currently represented by
:numeric
or complex dictionary types. It would be much simpler if we could write functions against some sort of:use-code
type, and choose how to represent those values at runtime.This proposal
This is a proposal to add "host types" - types that Dentaku doesn't necessarily know about, but that can be accessed or created through Opencounter-provided functions. They use the same syntax as concrete types - for example
:entity
or:use-code
would be considered a host type. They may also take arguments - for example:my-cool-container(:numeric)
.For example,
This places no restrictions on how these values are represented at runtime - they could be numbers, strings, Ruby objects, or hashes. But the checker will guarantee that a value of type
:my-cool-type
will only ever show up in places where it is expected.Potential Issues
:numeric
. Should this be different? This would require a little bit of customization to the:param
TypeExpression, since they have identical solving semantics and I'd like to avoid duplication.