Reading diagrams / Topic 17 of 42
What types promise
The rule
A type can promise things the code cannot break. A definition generic over a type can only pass values of that type along. It has no way to look inside them. The structure lens marks such definitions as generic.
The opposite case is a choice made by comparing a plain String or Int. No type ties the value to the cases it picks between, so a misspelled case still compiles. The lens lists these choices.
- A line reading “generic over” confirms that a definition never looks inside those values.
- A choice listed by plain String or Int rules out a typed key.
A small copy of a Redux todo app.
Loading the structure picture.
The Koa program’s choices by plain String.
Loading the structure picture.
How to read this: what each mark in these pictures means
Loading the worked examples and practice.