type-systems - Concepts
Explore concepts tagged with "type-systems"
Total concepts: 11
Concepts
- Stringly Typed - Code that uses plain strings for values that deserve a real type, such as states, keys, dates or identifiers, so the compiler can't catch mistakes that a proper type would prevent.
- Algebraic Data Types - Composite types built by combining other types in two ways: "and" (product types, like records) and "or" (sum types, like tagged unions), which lets you model a domain precisely.
- Typestate Pattern - A design technique that encodes an object's current state in its type, so calling an operation in the wrong state becomes a compile-time error instead of a runtime bug.
- Parse, Don't Validate - Turn untrusted input into precise, typed data at the edge of your system, instead of checking it and passing the same loose data along.
- Smart Constructor - A function that is the only way to create a value of a given type and that checks the type's rules, so every value that exists is guaranteed to be valid.
- Make Illegal States Unrepresentable - Design your data types so that invalid combinations of values simply can't be created, and let the compiler catch a whole class of bugs for you.
- Option Type - A type that makes the possible absence of a value explicit: a value is either present (Some(x)) or absent (None), and the compiler forces you to handle both cases.
- Null References - The practice of letting any reference point to "nothing", which Tony Hoare, who introduced it in 1965, later called his "billion-dollar mistake".
- Total Functions - A total function returns a valid result for every possible input of its type; a partial function only works for some inputs and crashes, throws or misbehaves on the others.
- Newtype Pattern - A technique that wraps an existing type (often a primitive) in a new, distinct type, so the compiler can tell apart values that share a representation but mean different things.
- Static Typing - A way of checking the types of values in a program before it runs, so a whole class of errors gets caught by the compiler or type checker instead of by your users.
← Back to all concepts