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

WIP: types: use tail recursive variadic tuple to type check pluggable arrays #96

Conversation

ChristianMurphy
Copy link
Member

alternative to #92

This approaches the typing from the perspective of tail recursion.
Each call to PluggableList will handle the type of the first/head item of the list, the it will recurse for all other items in the list.

TODO:

  • either the syntax is off, or the inference is not currently working, more investigation is needed, help is welcome!

@ChristianMurphy ChristianMurphy added ☂️ area/types This affects typings 🦋 type/enhancement This is great to have 🧒 semver/minor This is backwards-compatible change help wanted 🙏 This could use your insight or help 🛠 blocked/wip This cannot progress yet, it’s being worked on labels Aug 21, 2020
@ChristianMurphy
Copy link
Member Author

/cc @remcohaszing

@Murderlon
Copy link
Member

This looks cool.

But I’m not sure if I’m up to speed the implementation details. Are these assumptions correct?

with #92

// ..
.use<A, B, C>([pluginA, pluginB, pluginC]) // Matches types in the same order. Repetition required, even if types are the same.
// ..

with #96 (this)

// ..
.use<A, R>([pluginA, pluginB, pluginC]) // `A` is matched with pluginA and `R` with pluginB and pluginC
// ..

@ChristianMurphy
Copy link
Member Author

ChristianMurphy commented Aug 26, 2020

Excellent question

In both cases the goal is to support type inferencing.

.use([pluginA, [pluginB, settingsB], presetC])

should work.


Explicitly showing the types for #92

.use<SettingsA, SettingsB, SettingsC>([pluginA, [pluginB, settingsB], presetC])

with the limitation that it would no longer check after 10 items are added to use.


Explicitly showing the types for #96

.use<SettingsA, PluggableList<SettingsB, PluggableList<SettingsC, []>>>([pluginA, [pluginB, settingsB], presetC])

where PluggableList is a recursive type, which types a single plugin setting, and recurses to support any other plugins' settings.
The advantage being that it should support any number of parameters passed.

@wooorm
Copy link
Member

wooorm commented Nov 11, 2020

What is blocking this?

@ChristianMurphy
Copy link
Member Author

getting the typing to work 🙂
closing this for now, will revisit later if there is interest

@ChristianMurphy ChristianMurphy deleted the types/tail-recursive-pluggable-list branch November 11, 2020 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
☂️ area/types This affects typings 🛠 blocked/wip This cannot progress yet, it’s being worked on help wanted 🙏 This could use your insight or help 🧒 semver/minor This is backwards-compatible change 🦋 type/enhancement This is great to have
Development

Successfully merging this pull request may close these issues.

None yet

3 participants