You are previewing Programming F# 3.0, 2nd Edition.

Programming F# 3.0, 2nd Edition

Cover of Programming F# 3.0, 2nd Edition by Chris Smith Published by O'Reilly Media, Inc.
  1. Programming F# 3.0
  2. Preface
    1. Introducing F#
    2. Who This Book Is For
    3. What You Need to Get Going
    4. How the Book Is Organized
      1. Part I
      2. Part II
      3. Part III
    5. Part IV
    6. Conventions Used in This Book
    7. Using Code Examples
    8. Safari® Books Online
    9. I’d Like to Hear from You
    10. Acknowledgments
  3. I. Multiparadigm Programming
    1. 1. Introduction to F#
      1. Getting to Know F#
      2. Visual Studio 11
      3. F# Interactive
      4. Managing F# Source Files
    2. 2. Fundamentals
      1. Primitive Types
      2. Comparison and Equality
      3. Functions
      4. Core Types
      5. Organizing F# Code
    3. 3. Functional Programming
      1. Understanding Functions
      2. Pattern Matching
      3. Discriminated Unions
      4. Records
      5. Lazy Evaluation
      6. Sequences
      7. Queries
    4. 4. Imperative Programming
      1. Understanding Memory in .NET
      2. Changing Values
      3. Units of Measure
      4. Arrays
      5. Mutable Collection Types
      6. Looping Constructs
      7. Exceptions
    5. 5. Object-Oriented Programming
      1. Programming with Objects
      2. Understanding System.Object
      3. Understanding Classes
      4. Methods and Properties
      5. Inheritance
    6. 6. .NET Programming
      1. The .NET Platform
      2. Interfaces
      3. Object Expressions
      4. Extension Methods
      5. Extending Modules
      6. Enumerations
      7. Structs
  4. II. Programming F#
    1. 7. Applied Functional Programming
      1. Active Patterns
      2. Using Modules
      3. Mastering Lists
      4. Tail Recursion
      5. Programming with Functions
      6. Functional Patterns
      7. Functional Data Structures
    2. 8. Applied Object-Oriented Programming
      1. Operators
      2. Generic Type Constraints
      3. Delegates and Events
      4. Events
    3. 9. Asynchronous and Parallel Programming
      1. Working with Threads
      2. Asynchronous Programming
      3. Asynchronous Workflows
      4. Parallel Programming
      5. Task Parallel Library
    4. 10. Scripting
      1. F# Script Files
      2. Directives
      3. F# Script Recipes
    5. 11. Data Processing
      1. Indexing
      2. Querying
  5. III. Extending the F# Language
    1. 12. Reflection
      1. Attributes
      2. Type Reflection
      3. Dynamic Instantiation
      4. Using Reflection
    2. 13. Computation Expressions
      1. Toward Computation Expressions
      2. Computation Expression Builders
      3. Custom Computation Expression Builders
    3. 14. Quotations
      1. Quotation Basics
      2. Generating Quotation Expressions
    4. 15. Type Providers
      1. Typed Data Versus Typed Languages
      2. Type Providers
  6. IV. Appendixes
    1. A. Overview of .NET Libraries
      1. Visualization
      2. Data Processing
      3. Storing Data
    2. B. F# Interop
      1. .NET Interop
      2. Unmanaged Interop
  7. Index
  8. About the Author
  9. Colophon
  10. Copyright

Chapter 11. Data Processing

You have been exposed to just about every core feature of the F# programming language and seen how to program in the functional, imperative, and object-oriented styles. However, in order to develop a deep understanding of a language, you need to actually go out and use it. If you don’t have an F# starter project in mind, well, this chapter should hopefully serve as the next-best thing.

This chapter focuses on the application of the F# programming language. However, there is not a canonical F# application. The language is well suited across multiple domains and industries. Yet in all cases, F# is best suited for the computational core of a program, or the numeric heavy lifting and data processing.

With that in mind, we will write a simple search engine using F#. Along the way, you will learn about MapReduce-style data processing and using Lex and Yacc for generating parsers. Although this F# search engine will not rival Google any time soon, it will serve as a large-enough code base to practice idiomatic F#.

Of course, a detailed look at the source code for a search engine and the technologies powering it could easily fill several books, so this chapter only covers the key concepts. For more detail, see the source code found on GitHub at:

Before we begin, let’s quickly cover the major components of the project, which, despite each one leading down a technically interesting rabbit hole, are not that difficult ...

The best content for your career. Discover unlimited learning on demand for around $1/day.