liveBook · Manning

Type inference

Type inference is the automatic deduction of program or expression types from available values, context, and constraints without requiring explicit type annotations.

How 16 Manning books explain it

F# in Action: A Revised Edition of Get Programming with F#

Type inference is the compile-time deduction of expression and value types from available program information.

How it is used
Supports succinct statically typed F# code while composing functions, modeling records, matching patterns, and passing functions.
How deep it goes
Explains inference through bindings, functions, records, diagnostics, limitations, and IDE inspection; defers object-oriented details.
Examples
Uses integer bindings, an age-classification error exercise, record construction, pattern matching, and pluggable customer printers.
What you can do after
Diagnose/debug with compiler type displays and targeted annotations when inferred types create unexpected errors.

Read how F# in Action: A Revised Edition of Get Programming with F# explains type inference →

Building User-Friendly DSLs

Type inference is the algorithmic determination of expression or value types from available constraints without requiring every type to be written explicitly.

How it is used
Derives expression types for DSL projection when local AST data alone is insufficient.
How deep it goes
Implements ancestor-based inference for numbers and defers richer Hindley-Milner-style algorithms.
Examples
Uses rental-price expressions, Number objects, attributes, and the “-” and “of” operators.
What you can do after
Build it from scratch by passing AST ancestors into typeOf and centralizing contextual type logic.

Read how Building User-Friendly DSLs explains type inference →

Essential TypeScript 5, Third Edition

Type inference is the compiler's derivation of types for program elements from their values, expressions, and usage without explicit annotations.

How it is used
Checks variables, calculations, method calls, and arrays without requiring annotations at every use.
How deep it goes
Works through inferred expression and array types, then examines empty-array and subclass pitfalls and conditional-type inference.
Examples
Uses a tax calculation, a todo-list method error, initialized and empty arrays, subclass arrays, and generic property selection.
What you can do after
Diagnose/debug with it by checking inferred types in declaration files and adding annotations where inference permits errors or excludes intended values.

Read how Essential TypeScript 5, Third Edition explains type inference →

React in Depth

Type inference is the compiler's determination of a type from available values, expressions, or contextual constraints without an explicit type annotation.

How it is used
Uses inference to avoid redundant annotations while identifying React hook and callback initializers that need explicit types.
How deep it goes
Works through inferred results, generic arguments, state, context, and callback placement; does not explain compiler internals.
Examples
Uses a Fibonacci function, an appointment response, a tag form, dark-mode context, and playlist callbacks.
What you can do after
Apply it via TypeScript type arguments and annotations when React initializers or callback placement leave intended types unclear.

Read how React in Depth explains type inference →

Kotlin in Action, 2E

Type inference is the compiler's ability to determine expression types without requiring explicit type annotations everywhere.

How it is used
Reduces type-declaration boilerplate while preserving Kotlin’s statically known expression types.
How deep it goes
Explains inference from variable initializers and generic collection arguments, including cases where missing information requires explicit types.
Examples
Uses inferred `Int`, `String`, and `Double` variables plus string lists and explicitly typed empty mutable lists.
What you can do after
Apply it via Kotlin variable declarations and collection creators to omit types the compiler can deduce.

Read how Kotlin in Action, 2E explains type inference →

Modern C, Third Edition

Type inference is the compile-time deduction of type information from an expression or declaration without explicitly writing the complete type.

How it is used
Supports type-generic programming by deriving declarations from expressions and reducing repetitive type-specific cases.
How deep it goes
Explains C23 inference through declarations and a generic SWAP macro, while only summarizing broader typeof applications.
Examples
Uses inferred declarations, explicit declarations, and a generic SWAP macro with inferred pointers and temporary storage.
What you can do after
Build generic C macros that preserve operand-dependent types and evaluate captured expressions only once.

Read how Modern C, Third Edition explains type inference →

DuckDB in Action

Type inference is the automatic determination of data types from available program or expression information.

How it is used
Uses available annotations or file values to reduce manual schema work when registering functions and loading CSV data.
How deep it goes
Explains annotation-based and CSV-based inference, then contrasts them with explicit declarations and schema maintenance.
Examples
Demonstrates remove_spaces registration, Region cleanup, and Stack Overflow Users and Posts imports using automatic CSV detection.
What you can do after
Apply it via DuckDB to register Python functions and load CSV tables, while recognizing when explicit types are safer.

Read how DuckDB in Action explains type inference →

Learn Haskell by Example

Type inference is the automatic determination of expression and variable types from their usage and surrounding context.

How it is used
Uses inferred types to develop typed cipher-program definitions while retaining explicit top-level signatures for clarity.
How deep it goes
Explains contextual inference for numeric values and collections, then demonstrates polymorphic specialization without covering type-class constraints.
Examples
Uses cipher-wheel keys, numeric prefixes, typed lists and tuples, and a transform function specialized from Int to String.
What you can do after
Evaluate/understand how Haskell deduces concrete expression and function types from annotations, collection types, and polymorphic use.

Read how Learn Haskell by Example explains type inference →

100 C++ Mistakes and How to Avoid Them

Type inference is the compiler's process of determining a program entity's type from available declarations, initializers, or contextual information.

How it is used
Uses auto to simplify variable, iterator, template, and range-based loop declarations while preserving practical type awareness.
How deep it goes
Explains compiler deduction through iterator, reference, copying, and unsigned-loop examples, without formal deduction rules.
Examples
Uses iterator declarations, student-name copies, range-based student loops, and an unsigned reverse-index failure.
What you can do after
Apply it via C++ auto to shorten declarations, avoid unnecessary copies, and diagnose signedness hazards in loops.

Read how 100 C++ Mistakes and How to Avoid Them explains type inference →

Learn Go with Pocket-Sized Projects

Type inference is the compiler's deduction of a generic type argument from the types of a function's input arguments.

How it is used
Simplifies calls to reusable generic functions by letting the compiler select concrete type arguments from input values.
How deep it goes
Explains input-based deduction and its returned-type limitation, while stopping short of compiler algorithm internals.
Examples
Uses a generic prettyPrint function called with float64 and string arguments.
What you can do after
Apply it via Go generic functions by omitting type arguments when input parameters determine them.

Read how Learn Go with Pocket-Sized Projects explains type inference →

Modern Angular

Type inference is the determination of static types from expressions and their surrounding usage without explicit type annotations.

How it is used
Improves Angular dependency injection and reactive-form development by replacing implicit any and fragile token or control-name typing.
How deep it goes
Explains inferred token and form types, partial values, casts, dot notation, and template diagnostics, but not inference internals.
Examples
Uses application-wide date constants, inject(Constants), and an HRMS employee form whose misspelled email control triggers a template error.
What you can do after
Diagnose Angular injection and form-control mismatches earlier through inferred properties, typed values, and template checking.

Read how Modern Angular explains type inference →

.NET in Action, Second Edition

Type inference is the compiler's deduction of a program expression or variable's type from available context and assignments.

How it is used
Frames compiler deduction while service examples show explicitly typed ASP.NET Core handler parameters.
How deep it goes
Defines deduction from context and assignments but stops short of explaining inference rules, runtime behavior, or implementation internals.
Examples
Uses ASCII-art web endpoints whose route and query parameters are declared as `string` and `string?`.

Read how .NET in Action, Second Edition explains type inference →

Fabulous Adventures in Data Structures and Algorithms

Type inference is the deduction of expression or variable types from program context and constraints without requiring every type to be written explicitly.

How it is used
Explains omitted generic and lambda types by translating inference into a unification problem.
How deep it goes
Works through term construction and substitutions, but stops short of a full type-inference implementation.
Examples
Uses a generic Frob method, a numeric argument, a collection-producing lambda, and explicit inferred substitutions.
What you can do after
Evaluate how unification solves a small generic method-inference problem and interpret each resulting substitution.

Read how Fabulous Adventures in Data Structures and Algorithms explains type inference →

Refactoring to Rust

Type inference is the compile-time deduction of expression or variable types from program context without requiring explicit annotations.

How it is used
Uses compiler-deduced local types to reduce annotation effort while preserving static checking in Rust programs.
How deep it goes
Explains inference through initializers and map insertion, while deferring detailed annotation cases to later treatment.
Examples
Contrasts Java and Rust map declarations and demonstrates inferred artwork variables initialized with structs and strings.
What you can do after
Apply it via the Rust compiler by omitting routine local annotations while checking that surrounding values constrain the intended types.

Read how Refactoring to Rust explains type inference →

100 Go Mistakes and How to Avoid Them

Type inference is the compile-time deduction of generic type arguments from a call or use context.

How it is used
Uses call context to select generic type arguments while preserving compile-time type safety.
How deep it goes
Demonstrates inferred and explicit calls, but does not detail the compiler's inference algorithm.
Examples
Uses getKeys on map[string]int and contrasts inferred getKeys(m) with explicit getKeys[string](m).
What you can do after
Apply it via generic functions by choosing inferred calls when arguments suffice and explicit type arguments when clarity requires them.

Read how 100 Go Mistakes and How to Avoid Them explains type inference →

Fast Python: High performance techniques for large datasets

How it is used
Diagnoses inefficient pandas imports and guides explicit column conversion for memory-conscious data processing.
How deep it goes
Explains warnings, profiles column memory, and demonstrates conversions, but does not detail the inference algorithm internals.
Examples
Uses datetime columns, payment_type, and store_and_fwd_flag to demonstrate inferred-type diagnosis and narrowing.
What you can do after
Apply it via pandas to inspect inferred dtypes and reduce DataFrame memory consumption.

Read how Fast Python: High performance techniques for large datasets explains type inference →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.