Real-World Functional Programming
With examples in F# and C#
Tomas Petricek with Jon Skeet
Foreword by Mads Torgersen
  • December 2009
  • ISBN 9781933988924
  • 560 pages
  • printed in black & white

From the Foreword: You will never look at your code in the same way again.

Mads Torgersen, C# PM, Microsoft

Functional programming languages are good at expressing complex ideas in a succinct, declarative way. Functional concepts such as "immutability" and "function values" make it easier to reason about code—as well as helping with concurrency. The new F# language, LINQ, certain new features of C#, and numerous .NET libraries now bring the power of functional programming to .NET coders.

This book teaches the ideas and techniques of functional programming applied to real-world problems. You'll see how the functional way of thinking changes the game for .NET developers. Then, you'll tackle common issues using a functional approach. The book will also teach you the basics of the F# language and extend your C# skills into the functional domain. No prior experience with functional programming or F# is required.

Table of Contents show full

foreword

preface

acknowledgments

about this book

about the cover illustration

resources

Part 1 Learning to think functionally

1. Thinking differently

1.1. What is functional programming?

1.2. The path to real-world functional programming

1.3. Being productive with functional programming

1.4. Functional programming by example

1.5. Introducing F#

1.6. Summary

2. Core concepts in functional programming

2.1. The foundation of functional programming

2.2. Evaluation of functional programs

2.3. Writing declarative code

2.4. Functional types and values

2.5. Summary

3. Meet tuples, lists, and functions in F# and C#

3.1. Value and function declarations

3.2. Using immutable data structures

3.3. Lists and recursion

3.4. Using functions as values

3.5. Summary

4. Exploring F# and .NET libraries by example

4.1. Drawing pie charts in F#

4.2. Writing and testing code in FSI

4.3. Creating a console application

4.4. Creating a Windows Forms application

4.5. Summary

Part 2 Fundamental functional techniques

5. Using functional values locally

5.1. What are values?

5.2. Multiple values

5.3. Alternative values

5.4. Generic values

5.5. Function values

5.6. Summary

6. Processing values using higher-order functions

6.1. Generic higher-order functions

6.2. Working with tuples

6.3. Working with schedules

6.4. Working with the option type

6.5. Working with functions

6.6. Type inference

6.7. Working with lists

6.8. Common processing language

6.9. Summary

7. Designing data-centric programs

7.1. Functional data structures

7.2. Flat document representation

7.3. Structured document representation

7.4. Writing operations

7.5. Object-oriented representations

7.6. Summary

8. Designing behavior-centric programs

8.1. Using collections of behaviors

8.2. Idioms for working with functions

8.3. Working with composed behaviors

8.4. Combining data and behaviors

8.5. Summary

Part 3 Advanced F# programming techniques

9. Turning values into F# object types with members

9.1. Improving data-centric applications

9.2. Improving behavior-centric applications

9.3. Working with .NET interfaces

9.4. Concrete object types

9.5. Using F# libraries from C#

9.6. Summary

10. Efficiency of data structures

10.1. Optimizing functions

10.2. Working with large collections

10.3. Introducing continuations

10.4. Summary

11. Refactoring and testing functional programs

11.1. Refactoring functional programs

11.2. Testing functional code

11.3. Refactoring the evaluation order

11.4. Using lazy values in practice

11.5. Summary

12. Sequence expressions and alternative workflows

12.1. Generating sequences

12.2. Mastering sequence expressions

12.3. Processing sequences

12.4. Introducing alternative workflows

12.5. First steps in custom computations

12.6. Implementing computation expressions for options

12.7. Augmenting computations with logging

12.8. Summary

Part 4 Applied functional programming

13. Asynchronous and data-driven programming

13.1. Asynchronous workflows

13.2. Connecting to the World Bank

13.3. Exploring and obtaining the data

13.4. Gathering information from the data

13.5. Visualizing data using Excel

13.6. Summary

14. Writing parallel functional programs

14.1. Understanding different parallelization techniques

14.2. Running graphical effects in parallel

14.3. Creating a parallel simulation

14.4. Summary

15. Creating composable functional libraries

15.1. Approaches for composable design

15.2. Creating animated values

15.3. Writing computations with behaviors

15.4. Working with drawings

15.5. Creating animations

15.6. Developing financial modeling language

15.7. Summary

16. Developing reactive functional programs

16.1. Reactive programming using events

16.2. Creating reactive animations

16.3. Programming UIs using workflows

16.4. Storing state in reactive applications

16.5. Message passing concurrency

16.6. Summary

Appendix A: appendix : Looking ahead

index

© 2014 Manning Publications Co.

About the Technology

Functional programming languages are good at expressing complex ideas in a succinct, declarative way. Functional concepts such as "immutability" and "function values" make it easier to reason about code—as well as helping with concurrency. The new F# language, LINQ, certain new features of C#, and numerous .NET libraries now bring the power of functional programming to .NET coders.

About the book

This book teaches the ideas and techniques of functional programming applied to real-world problems. You'll see how the functional way of thinking changes the game for .NET developers. Then, you'll tackle common issues using a functional approach. The book will also teach you the basics of the F# language and extend your C# skills into the functional domain. No prior experience with functional programming or F# is required.

What's inside

  • Thinking the functional way
  • Blending OO and functional programming
  • Effective F# code

About the authors

Microsoft C# MVP Tomas Petricek is one of the leaders of the F# community. He was part of the Microsoft Research team for F# and is interested in distributed and reactive programming using F#. Microsoft C# MVP Jon Skeet is a veteran C# and Java developer, prolific "Stack Overflow" contributor, and author of C# in Depth.


combo $49.99 pBook + eBook
eBook $39.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

A truly functional book!

Andrew Siemer, .NET Architect

.NET needs more functional programmers...this book shows you how to become one.

Stuart Caborn, Lead Consultant Thoughtworks

Warning: this book has a very high Wow! factor. It made my head hurt...in a good way!

Mark Seemann, Developer/Architect, Safewhere

I recommend it to all software craftspeople, not just .NET developers.

Paul King, Director, ASERT