Effective Haskell: Solving Real-World Problems with Strongly Typed Functional Programming

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Put the power of Haskell to work in your programs, learning from an engineer who uses Haskell daily to get practical work done efficiently. Leverage powerful features like Monad Transformers and Type Families to build useful applications. Realize the benefits of a pure functional language, like protecting your code from side effects. Manage concurrent processes fearlessly. Apply functional techniques to working with databases and building RESTful services. Don't get bogged down in theory, but learn to employ advanced programming concepts to solve real-world problems. Don't just learn the syntax, but dive deeply into Haskell as you build efficient, well-tested programs. Haskell is a pure functional programming language with a rich ecosystem of tools and libraries. Designed to push the boundaries of programming, it offers unparalleled power for building reliable and maintainable systems. But to unleash that power, you need a guide. Effective Haskell is that guide. Written by an engineer who understands how to apply Haskell to the real world and uses it daily to get practical work done, it is your ticket to Haskell mastery. Gain deep understanding of how Haskell deals with IO and the outside world by writing a complete Haskell application that does several different kinds of IO. Reinforce your learnings with practice exercises in every chapter. Write stable and performant code using Haskell's type system, code that is easier to grow and refactor. Leverage the power of pure functional programming to improve collaboration, make concurrency safe and easy, and make large code bases manageable. Implement type-safe web services, write generative tests, design strongly typed embedded domain-specific languages, and build applications that exploit parallelism and concurrency without fear of deadlocks and race conditions. Create and deploy cloud-native Haskell applications. Master the performance characteristics of functional applications to make them run faster and use less memory. Write Haskell programs that solve real-world business problems. What You Need: • Intel based Mac, M1 Macs, Linux PC, or Windows with WSL2 • ghcup (http://www. Haskell.org/ghcup/) • An active internet connection will be required for some projects.

Author(s): Rebecca Skinner
Edition: 1
Publisher: Pragmatic Bookshelf
Year: 2023

Language: English
Commentary: Publisher's PDF | Book version: P1.0—July 2023 | Published: August 2023
Pages: 668
City: Raleigh, NC
Tags: Programming; Functional Programming; Haskell Monads; Type-Driven Development; Elementary; Data Serialization

Cover
Table of Contents
Acknowledgments
Foreword
Introduction
Why Choose Haskell?
Why This Book
How to Read This Book
1. Getting Started with Haskell
Exploring Haskell Interactively
Writing Your First Haskell Program
Formatting Haskell Code
Creating New Variables
Writing Functions
Precedence, Operators, and Fixity
Creating Local Variables Using Let Bindings
Running Code Conditionally Using Branches
Looping
Summary
Exercises
2. Working with Lists
Writing Code Using Lists
Destructuring Values with Pattern Matching
Understanding How Programs Are Evaluated
Hands-On with Infinite Fibonacci Numbers
Summary
Exercises
3. Getting Started with Types
Working with Basic Haskell Types
Annotating Values with Type Information
Looking Up Type Information
Writing Type Annotations for Functions
Reading Type Errors
Working with Polymorphic Functions
Exploring the Type Space of an Application with Undefined
Getting Help from Type Holes
Looking at the Type of main
Summary
Exercises
4. Creating New Types
Creating Data Types and Records
Creating Sum Types
Creating Inductively Defined Data Structures
Building a Calculator
Functions as Values
Creating Type Aliases
Summary
Exercises
5. Creating And Structuring Haskell Projects
Creating Haskell Projects
Using Code from Other Modules
Creating Your Own Modules
Choosing What to Export
Documenting Modules
Summary
Exercises
6. Type Classes
Using Ad Hoc Polymorphism with Type classes
Specifying Type Class Instances with Type Applications
Wrapping Types with Newtype
Understanding Higher Kinded Types and Polymorphism
Deriving Instances
Deriving More Things
Summary
Exercises
7. Understanding IO
Talking About IO
Performing IO in a Pure, Lazy Language
Ordering and Combining IO Actions
Independently Sequencing IO Actions
Mapping IO Values with fmap
Running IO in Real Applications
Summary
Exercises
8. Working with the Local System
Building Applications with IO
Procedural Shell, Functional Core
Creating a Pager
Viewing the Contents of an ASCII or UTF8 Encoded Text File
Viewing Text One Page at a Time
Adding a Status Line with Metadata
Showing the Status Bar and Refactoring runHCat
Summary
Exercises
9. Introducing Monads
Mapping Functors
Applying Applicatives
Working with the Monad Type Class
Understanding the Laws of the Land
Using the Functor Laws
Using the Monad Laws
Using the Applicative Laws
Summary
Exercises
10. Mutable Data in the Real World
Using Mutable References in a Pure Language
Working with IORefs
Building a Basic Metrics System with IORefs
Dealing with Laziness and IO
Summary
Exercises
11. Serializing Heterogenous Data
Heterogenous Data in Haskell
A First Pass at a File Archiver
Serializing with Type Classes
Building a List of FileData Values
Summary
Exercises
12. Deserializing Heterogenous Data
Extracting Heterogenous Values from the Archive
Deserialization as Parsing
Creating a Parsing Function
Building a Monadic Parser
Parsing a List of Values
Adding a Monad Instance
Adding a MonadFail Instance
Summary
Exercises
13. Building Applications with Many Effects
Revisiting the Parsing Problem
Handling Errors in Other Computations
State, Transformed
Stacking Transformers Effectively
Building a File Archiver
Summary
Exercises
14. Building Efficient Programs
Building a Naive Spellchecker
Memoizing editDistance
Internal Mutability with ST
Optimizing Memory Layout with Vectors
The Fastest Edit Distance
Summary
Exercises
15. Programming with Types
What Is Type Level Programming?
Types and Kinds
Functions from Types to Types
GADTs: Functions from Terms to Types
Type Classes: Functions from Types to Terms
Summary
Exercises
Index
– SYMBOLS –
– A –
– B –
– C –
– D –
– E –
– F –
– G –
– H –
– I –
– J –
– K –
– L –
– M –
– N –
– O –
– P –
– Q –
– R –
– S –
– T –
– U –
– V –
– W –
– X –
– Z –