TYPE SYSTEMS / FIELD GUIDERULE SELECTED
A practical variance lens

Types move. Callbacks reveal why.

Switch between the direction cues behind +T and -T, then test your intuition against the callback rule that makes bivariance dangerous.

Pick a rule

direction cue

Outputs flow outward

Covariance is the easier direction to picture: if a function produces a specific kind of value, code expecting a broader kind can consume it.

type Producer<+T> = () => T
Ask: can the consumer safely read the more specific value as the broader type?

Trace the variance worksheet without assuming compiler proof

Read the explanation

The source offers three conceptual rule panels: covariance, contravariance and bivariance. Its covariance cue follows outputs: a producer returning a specific value can be used where a broader value is expected. Its contravariance cue follows inputs: a callback must accept the full range of values its caller can provide. The arrows here label these conceptual directions only. This page does not run a compiler or validate the displayed illustrative type syntax. Selecting a rule changes the active button and replaces the title, explanation, example and safety cue with that rule’s fixed source content. Bivariance accepts compatibility both ways, and the source warns that this convenience can hide a callback that rejects a value a caller may send. Selection does not prove a program is safe. Use the note field to record a concrete boundary question and inspect the actual compiler and language settings separately. Both the selected rule and note are saved locally when changed. Reload restores them. Export downloads the full selected rule, title, explanation, example, safety cue, question and explicit conceptual boundary. Reset selects covariance, clears the note and removes the saved local state. A file already downloaded remains outside that reset. None of these actions contacts a model or compiles source code.

Super generates helpful tools and automates fact-checking across the internet proactively. If you enjoyed this tool, build your own with Super and share it with a friend.