-
Notifications
You must be signed in to change notification settings - Fork 79
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
As a library programmer, I want to pass type arguments so that I can write more generic/reusable libraries #53
Comments
This feels more like a service factory, rather than an actual service. From |
I think this stance makes sense, but I'm not certain that I agree (yet). Just to clarify, are you saying that type arguments are never an issue for Candid, and only ever for a language using Candid, like Motoko? |
I think it's still nice for Candid to support type arguments, but I'm not sure how useful it is for a container canister. Even for a local function, I don't know what to do with a generic |
#245 subsumes this discussion. |
Also include some cleanup of the scripts that arent used, and add a diagram for the bootstrapping process. This does not affect the worker yet. Only the first retrieve of the index.js on localhost. BREAKING CHANGE If a canister has a retrieve() method that relies on Principal, the principal used will change. Co-authored-by: Benjamin Goering <benjamin.goering@dfinity.org>
Is your feature request related to a problem? Please describe.
I want to write an actor/service like this in Motoko, with a corresponding Candid service type:
Leaving out some inessential details, this
MapThing
actor provides a service whose API is parametric in two types,X
andY
, for a generic key and value type, respectively. It stores a dynamic map fromX
s toY
s.More generally, I want to author Candid services that use generic type arguments, and as a user, instantiate services by providing these types over the network.
Describe the solution you'd like
The solution here involves extending Candid, Motoko, as well as (perhaps) the Internet Computer itself.
Describe alternatives you've considered
Many systems and languages lack polymorphic types. The usual workarounds map a polymorphic design into a monomorphic one, somehow. For instance, we could assume a single choice of type for
X
andY
above, and try to provide a way to map into and out of these single choices (e.g., use[nat8]
for all types and do extra layers of serialization, the current solution).Additional context
None.
The text was updated successfully, but these errors were encountered: