Existential type?
See original GitHub issueHere’s a case where I need a few existentials. It’s for a definition file, where I need to have parameters for Binding
and Scheduler
, but it doesn’t matter to me what they are. All I care about is that they’re internally correct (and any
doesn’t cover this), and I’d rather not simulate it by making the constructor unnecessarily generic.
The alternative for me is to be able to declare additional constructor-specific type parameters that don’t carry to other methods, but existentials would make it easier.
export interface Scheduler<Frame, Idle> {
nextFrame(func: () => any): Frame;
cancelFrame(frame: Frame): void;
nextIdle(func: () => any): Idle;
cancelIdle(frame: Idle): void;
nextTick(func: () => any): void;
}
export interface Binding<E> extends Component {
binding: E;
patchEnd?(): void;
patchAdd?(
prev: string | E | void,
next: string | E | void,
pos: number,
): void;
patchRemove?(
prev: string | E | void,
next: string | E | void,
pos: number
): void;
patchChange?(
oldPrev: string | E | void,
newPrev: string | E | void,
oldNext: string | E | void,
newNext: string | E | void,
oldPos: number,
newPos: number
): void;
}
export class Subtree {
constructor(
onError?: (err: Error) => any,
scheduler?: type<F, I> Scheduler<F, I>
);
// ...
}
export class Root extends Subtree {
constructor(
component: type<E> Binding<E>,
onError?: (err: Error) => any,
scheduler?: type<F, I> Scheduler<F, I>
);
// ...
}
Issue Analytics
- State:
- Created 7 years ago
- Reactions:77
- Comments:68 (19 by maintainers)
Top Results From Across the Web
Existential type - HaskellWiki
Use 'existential types' - an extension to Haskell that can be found in most compilers. ... where x, y, z can be from...
Read more >What is an existential type? - Stack Overflow
Universal/abstract types and existential types are a duality of perspective between the consumer/client of an object/function and the producer/implementation of ...
Read more >An Introduction to Existential Types | by Stephen Bly - Medium
Let's start with the what. Existential types allow us to create abstract data types: stacks, queues, maps, heaps, etc. More generally, they ...
Read more >Existential types in Rust | varkor's blog
An “existential type”, or “existentially-quantified type”, is a type that intuitively represents “any type satisfying a given property”. In the ...
Read more >existential type - Wiktionary
NounEdit · (programming, type systems) A type that hides the underlying concrete type(s). quotations ▽synonym △. Synonym: existential. 2002, Benjamin C. · Used ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Existential types would also be useful for arrays of generics.
Example:
For anyone interested in using existential types right now via the negation of universal types, the type annotation burden of doing so has been greatly reduced thanks to recent type inference improvements.