0%

Book Description

Programming with Types teaches type-based techniques for writing software that’s safe, correct, easy to maintain, and practically self-documenting. Designed for working developers, this clearly written tutorial sticks with the practical benefits of type systems for everyday programming tasks. Following real-world examples coded in TypeScript, you’ll build your skills from primitive types up to more-advanced concepts like functors and monads.

Table of Contents

  1. Copyright
    1. Dedication
  2. Brief Table of Contents
  3. Table of Contents
  4. Preface
  5. Acknowledgments
  6. About This Book
    1. Who should read this book
    2. How this book is organized: a road map
    3. About the code
    4. About the author
    5. Book forum
  7. About the Cover Illustration
    1. Saint-Sauver
  8. Chapter 1. Introduction to typing
    1. 1.1. Whom this book is for
    2. 1.2. Why types exist
    3. 1.3. Benefits of type systems
    4. 1.4. Types of type systems
    5. 1.5. In this book
    6. Summary
  9. Chapter 2. Basic types
    1. 2.1. Designing functions that don’t return values
    2. 2.2. Boolean logic and short circuits
    3. 2.3. Common pitfalls of numerical types
    4. 2.4. Encoding text
    5. 2.5. Building data structures with arrays and references
    6. Summary
    7. Answers to exercises
  10. Chapter 3. Composition
    1. 3.1. Compound types
    2. 3.2. Expressing either-or with types
    3. 3.3. The visitor pattern
    4. 3.4. Algebraic data types
    5. Summary
    6. Answers to exercises
  11. Chapter 4. Type safety
    1. 4.1. Avoiding primitive obsession to prevent misinterpretation
    2. 4.2. Enforcing constraints
    3. 4.3. Adding type information
    4. 4.4. Hiding and restoring type information
    5. Summary
    6. Answers to exercises
  12. Chapter 5. Function types
    1. 5.1. A simple strategy pattern
    2. 5.2. A state machine without switch statements
    3. 5.3. Avoiding expensive computation with lazy values
    4. 5.4. Using map, filter, and reduce
    5. 5.5. Functional programming
    6. Summary
    7. Answers to exercises
  13. Chapter 6. Advanced applications of function types
    1. 6.1. A simple decorator pattern
    2. 6.2. Implementing a counter
    3. 6.3. Executing long-running operations asynchronously
    4. 6.4. Simplifying asynchronous code
    5. Summary
    6. Answers to exercises
  14. Chapter 7. Subtyping
    1. 7.1. Distinguishing between similar types in TypeScript
    2. 7.2. Assigning anything to, assigning to anything
    3. 7.3. Allowed substitutions
    4. Summary
    5. Answers to exercises
  15. Chapter 8. Elements of object-oriented programming
    1. 8.1. Defining contracts with interfaces
    2. 8.2. Inheriting data and behavior
    3. 8.3. Composing data and behavior
    4. 8.4. Extending data and behavior
    5. 8.5. Alternatives to purely object-oriented code
    6. Summary
    7. Answers to exercises
  16. Chapter 9. Generic data structures
    1. 9.1. Decoupling concerns
    2. 9.2. Generic data layout
    3. 9.3. Traversing any data structure
    4. 9.4. Streaming data
    5. Summary
    6. Answers to exercises
  17. Chapter 10. Generic algorithms and iterators
    1. 10.1. Better map(), filter(), reduce()
    2. 10.2. Common algorithms
    3. 10.3. Constraining type parameters
    4. 10.4. Efficient reverse and other algorithms using iterators
    5. 10.5. Adaptive algorithms
    6. Summary
    7. Answers to exercises
  18. Chapter 11. Higher kinded types and beyond
    1. 11.1. An even more general map
    2. 11.2. Monads
    3. 11.3. Where to next?
    4. Summary
    5. 11.4. Answers to exercises
  19. Appendix A. TypeScript installation and source code
    1. Online
    2. Local
    3. Source Code
    4. DIY
  20. Appendix B. TypeScript cheat sheet
  21. Types and possible values
  22. Common algorithms
    1. map()
    2. filter()
    3. reduce()
  23. Index
  24. List of Figures
  25. List of Tables
  26. List of Listings
3.81.79.135