Book description
This easy-to-use, fast-moving tutorial introduces you to functional programming with Haskell. You'll learn how to use Haskell in a variety of practical ways, from short scripts to large and demanding applications. Real World Haskell takes you through the basics of functional programming at a brisk pace, and then helps you increase your understanding of Haskell in real-world issues like I/O, performance, dealing with data, concurrency, and more as you move through each chapter.
Publisher resources
Table of contents
- Real World Haskell
- Dedication
- A Note Regarding Supplemental Files
- Preface
- 1. Getting Started
-
2. Types and Functions
- Why Care About Types?
- Haskell’s Type System
- What to Expect from the Type System
- Some Common Basic Types
- Function Application
- Useful Composite Data Types: Lists and Tuples
- Functions over Lists and Tuples
- Function Types and Purity
- Haskell Source Files, and Writing Simple Functions
- Understanding Evaluation by Example
- Polymorphism in Haskell
- The Type of a Function of More Than One Argument
- Why the Fuss over Purity?
- Conclusion
-
3. Defining Types, Streamlining Functions
- Defining a New Data Type
- Type Synonyms
- Algebraic Data Types
- Pattern Matching
- Record Syntax
- Parameterized Types
- Recursive Types
- Reporting Errors
- Introducing Local Variables
- The Offside Rule and Whitespace in an Expression
- The case Expression
- Common Beginner Mistakes with Patterns
- Conditional Evaluation with Guards
-
4. Functional Programming
- Thinking in Haskell
- A Simple Command-Line Framework
- Warming Up: Portably Splitting Lines of Text
- Infix Functions
- Working with Lists
- How to Think About Loops
- Anonymous (lambda) Functions
- Partial Function Application and Currying
- As-patterns
- Code Reuse Through Composition
- Tips for Writing Readable Code
- Space Leaks and Strict Evaluation
-
5. Writing a Library: Working with JSON Data
- A Whirlwind Tour of JSON
- Representing JSON Data in Haskell
- The Anatomy of a Haskell Module
- Compiling Haskell Source
- Generating a Haskell Program and Importing Modules
- Printing JSON Data
- Type Inference Is a Double-Edged Sword
- A More General Look at Rendering
- Developing Haskell Code Without Going Nuts
- Pretty Printing a String
- Arrays and Objects, and the Module Header
- Writing a Module Header
- Fleshing Out the Pretty-Printing Library
- Creating a Package
- Practical Pointers and Further Reading
-
6. Using Typeclasses
- The Need for Typeclasses
- What Are Typeclasses?
- Declaring Typeclass Instances
- Important Built-in Typeclasses
- Automatic Derivation
- Typeclasses at Work: Making JSON Easier to Use
- Living in an Open World
- How to Give a Type a New Identity
- JSON Typeclasses Without Overlapping Instances
- The Dreaded Monomorphism Restriction
- Conclusion
- 7. I/O
- 8. Efficient File Processing, Regular Expressions, and Filename Matching
-
9. I/O Case Study: A Library for Searching the Filesystem
- The find Command
- Starting Simple: Recursively Listing a Directory
- A Naive Finding Function
- Predicates: From Poverty to Riches, While Remaining Pure
- Sizing a File Safely
- A Domain-Specific Language for Predicates
- Controlling Traversal
- Density, Readability, and the Learning Process
- Another Way of Looking at Traversal
- Useful Coding Guidelines
- 10. Code Case Study: Parsing a Binary Data Format
- 11. Testing and Quality Assurance
-
12. Barcode Recognition
- A Little Bit About Barcodes
- Introducing Arrays
- Encoding an EAN-13 Barcode
- Constraints on Our Decoder
- Divide and Conquer
- Turning a Color Image into Something Tractable
- What Have We Done to Our Image?
- Finding Matching Digits
- Life Without Arrays or Hash Tables
- Turning Digit Soup into an Answer
- Working with Row Data
- Pulling It All Together
- A Few Comments on Development Style
- 13. Data Structures
-
14. Monads
- Revisiting Earlier Code Examples
- Looking for Shared Patterns
- The Monad Typeclass
- And Now, a Jargon Moment
- Using a New Monad: Show Your Work!
- Mixing Pure and Monadic Code
- Putting a Few Misconceptions to Rest
- Building the Logger Monad
- The Maybe Monad
- The List Monad
- Desugaring of do Blocks
- The State Monad
- Monads and Functors
- The Monad Laws and Good Coding Style
- 15. Programming with Monads
-
16. Using Parsec
- First Steps with Parsec: Simple CSV Parsing
- The sepBy and endBy Combinators
- Choices and Errors
- Extended Example: Full CSV Parser
- Parsec and MonadPlus
- Parsing a URL-Encoded Query String
- Supplanting Regular Expressions for Casual Parsing
- Parsing Without Variables
- Applicative Functors for Parsing
- Applicative Parsing by Example
- Parsing JSON Data
- Parsing a HTTP Request
- 17. Interfacing with C: The FFI
-
18. Monad Transformers
- Motivation: Boilerplate Avoidance
- A Simple Monad Transformer Example
- Common Patterns in Monads and Monad Transformers
- Stacking Multiple Monad Transformers
- Moving Down the Stack
- Understanding Monad Transformers by Building One
- Transformer Stacking Order Is Important
- Putting Monads and Monad Transformers into Perspective
- 19. Error Handling
- 20. Systems Programming in Haskell
- 21. Using Databases
- 22. Extended Example: Web Client Programming
- 23. GUI Programming with gtk2hs
-
24. Concurrent and Multicore Programming
- Defining Concurrency and Parallelism
- Concurrent Programming with Threads
- Simple Communication Between Threads
- The Main Thread and Waiting for Other Threads
- Communicating over Channels
- Useful Things to Know About
- Shared-State Concurrency Is Still Hard
- Using Multiple Cores with GHC
- Parallel Programming in Haskell
- Parallel Strategies and MapReduce
- 25. Profiling and Optimization
- 26. Advanced Library Design: Building a Bloom Filter
- 27. Sockets and Syslog
- 28. Software Transactional Memory
- A. Installing GHC and Haskell Libraries
- B. Characters, Strings, and Escaping Rules
- Index
- About the Authors
- Colophon
- Copyright
Product information
- Title: Real World Haskell
- Author(s):
- Release date: November 2008
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596514983
You might also like
book
Effective Haskell
Put the power of Haskell to work in your programs, learning from an engineer who uses …
book
Haskell in Depth
Turn the corner from “Haskell student” to “Haskell developer.” Haskell in Depth explores the important language …
book
Practical Haskell: A Real-World Guide to Functional Programming
Get a practical, hands-on introduction to the Haskell language, its libraries and environment, and to the …
video
Learning Haskell Programming
Haskell is a powerful and well-designed functional programming language designed to work with complex data. Its …