Real World Ocaml

Item Information
Item#: 9781449323912
Author Minsky, Yaron
Cover Paperback
On Hand 0
 


This fast-moving tutorial introduces you to OCaml, an industrial-strength programming language designed for expressiveness, safety, and speed. Through the book’s many examples, you’ll quickly learn how OCaml stands out as a tool for writing fast, succinct, and readable systems code.

Real World OCaml takes you through the concepts of the language at a brisk pace, and then helps you explore the tools and techniques that make OCaml an effective and practical tool. In the book’s third section, you’ll delve deep into the details of the compiler toolchain and OCaml’s simple and efficient runtime system.

Learn the foundations of the language, such as higher-order functions, algebraic data types, and modulesExplore advanced features such as functors, first-class modules, and objectsLeverage Core, a comprehensive general-purpose standard library for OCamlDesign effective and reusable libraries, making the most of OCaml’s approach to abstraction and modularityTackle practical programming problems from command-line parsing to asynchronous network programmingExamine profiling and interactive debugging techniques with tools such as GNU gdb

Table of Contents
Dedication; Prologue; Why OCaml?; About This Book; Safari® Books Online; How to Contact Us; Contributors; Language Concepts; Chapter 1: A Guided Tour; 1.1 OCaml as a Calculator; 1.2 Functions and Type Inference; 1.3 Tuples, Lists, Options, and Pattern Matching; 1.4 Records and Variants; 1.5 Imperative Programming; 1.6 A Complete Program; 1.7 Where to Go from Here; Chapter 2: Variables and Functions; 2.1 Variables; 2.2 Functions; Chapter 3: Lists and Patterns; 3.1 List Basics; 3.2 Using Patterns to Extract Data from a List; 3.3 Limitations (and Blessings) of Pattern Matching; 3.4 Using the List Module Effectively; 3.5 Tail Recursion; 3.6 Terser and Faster Patterns; Chapter 4: Files, Modules, and Programs; 4.1 Single-File Programs; 4.2 Multifile Programs and Modules; 4.3 Signatures and Abstract Types; 4.4 Concrete Types in Signatures; 4.5 Nested Modules; 4.6 Opening Modules; 4.7 Including Modules; 4.8 Common Errors with Modules; 4.9 Designing with Modules; Chapter 5: Records; 5.1 Patterns and Exhaustiveness; 5.2 Field Punning; 5.3 Reusing Field Names; 5.4 Functional Updates; 5.5 Mutable Fields; 5.6 First-Class Fields; Chapter 6: Variants; 6.1 Catch-All Cases and Refactoring; 6.2 Combining Records and Variants; 6.3 Variants and Recursive Data Structures; 6.4 Polymorphic Variants; Chapter 7: Error Handling; 7.1 Error-Aware Return Types; 7.2 Exceptions; 7.3 Choosing an Error-Handling Strategy; Chapter 8: Imperative Programming; 8.1 Example: Imperative Dictionaries; 8.2 Primitive Mutable Data; 8.3 for and while Loops; 8.4 Example: Doubly Linked Lists; 8.5 Laziness and Other Benign Effects; 8.6 Input and Output; 8.7 Order of Evaluation; 8.8 Side Effects and Weak Polymorphism; 8.9 Summary; Chapter 9: Functors; 9.1 A Trivial Example; 9.2 A Bigger Example: Computing with Intervals; 9.3 Extending Modules; Chapter 10: First-Class Modules; 10.1 Working with First-Class Modules; 10.2 Example: A Query-Handling Framework; 10.3 Living Without First-Class Modules; Chapter 11: Objects; 11.1 OCaml Objects; 11.2 Object Polymorphism; 11.3 Immutable Objects; 11.4 When to Use Objects; 11.5 Subtyping; Chapter 12: Classes; 12.1 OCaml Classes; 12.2 Class Parameters and Polymorphism; 12.3 Object Types as Interfaces; 12.4 Inheritance; 12.5 Class Types; 12.6 Open Recursion; 12.7 Private Methods; 12.8 Binary Methods; 12.9 Virtual Classes and Methods; 12.10 Initializers; 12.11 Multiple Inheritance; Tools and Techniques; Chapter 13: Maps and Hash Tables; 13.1 Maps; 13.2 Hash Tables; 13.3 Choosing Between Maps and Hash Tables; Chapter 14: Command-Line Parsing; 14.1 Basic Command-Line Parsing; 14.2 Argument Types; 14.3 Adding Labeled Flags to the Command Line; 14.4 Grouping Subcommands Together; 14.5 Advanced Control over Parsing; 14.6 Command-Line Autocompletion with bash; 14.7 Alternative Command-Line Parsers; Chapter 15: Handling JSON Data; 15.1 JSON Basics; 15.2 Parsing JSON with Yojson; 15.3 Selecting Values from JSON Structures; 15.4 Constructing JSON Values; 15.5 Using Nonstandard JSON Extensions; 15.6 Automatically Mapping JSON to OCaml Types; Chapter 16: Parsing with OCamllex and Menhir; 16.1 Lexing and Parsing; 16.2 Defining a Parser; 16.3 Defining a Lexer; 16.4 Bringing It All Together; Chapter 17: Data Serialization with S-Expressions; 17.1 Basic Usage; 17.2 The Sexp Format; 17.3 Preserving Invariants; 17.4 Getting Good Error Messages; 17.5 Sexp-Conversion Directives; Chapter 18: Concurrent Programming with Async; 18.1 Async Basics; 18.2 Examples: An Echo Server; 18.3 Example: Searching Definitions with DuckDuckGo; 18.4 Exception Handling; 18.5 Timeouts, Cancellation, and Choices; 18.6 Working with System Threads; The Runtime System; Chapter 19: Foreign Function Interface; 19.1 Example: A Terminal Interface; 19.2 Basic Scalar C Types; 19.3 Pointers and Arrays; 19.4 Structs and Unions; 19.5 Passing Functions to C; 19.6 Learning More About C Bindings; Chapter 20: Memory Representation of Values; 20.1 OCaml Blocks and Values; 20.2 Blocks and Values; 20.3 Tuples, Records, and Arrays; 20.4 Variants and Lists; 20.5 Polymorphic Variants; 20.6 String Values; 20.7 Custom Heap Blocks; Chapter 21: Understanding the Garbage Collector; 21.1 Mark and Sweep Garbage Collection; 21.2 Generational Garbage Collection; 21.3 The Fast Minor Heap; 21.4 The Long-Lived Major Heap; 21.5 Attaching Finalizer Functions to Values; Chapter 22: The Compiler Frontend: Parsing and Type Checking; 22.1 An Overview of the Toolchain; 22.2 Parsing Source Code; 22.3 Preprocessing Source Code; 22.4 Static Type Checking; 22.5 The Typed Syntax Tree; Chapter 23: The Compiler Backend: Bytecode and Native code; 23.1 The Untyped Lambda Form; 23.2 Generating Portable Bytecode; 23.3 Compiling Fast Native Code; 23.4 Summarizing the File Extensions; Colophon;