优秀的Haskell图书

jopen 8年前

Haskell 是一种标准化的,非限定性语义、强静态类型的通用纯函数式编程语言。不同于其它大多数编程语言,它包含了许多较新的技术,如静态多态、高阶函数、用户定义 代数数据类型、模块系统等等。它内置了并发和并行性、以及调试器和分析器,有着丰富的库和活跃的社区,第三方开源库和工具数量接近 5000。这篇文章挑选了可免费下载的 优秀 Haskell 图书,帮助程序员深入理解和掌握这门语言。

1. Real World Haskell

优秀的Haskell图书
Website book.realworldhaskell.org
Author Bryan O'Sullivan, Don Stewart, and John Goerzen
Format HTML
Pages 714

Real World Haskell is an easy-to-use, fast-moving tutorial that introduces the reader to functional programming with Haskell.

The reader learns 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.

Chapters cover:

  • Getting started
  • Types and functions - provides an overview of Haskell's type system, and much of its syntax. It covers 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, and polymorphism in Haskell
  • Defining types, streamlining functions - build on this basic knowledge to further enhance our understanding of Haskell
  • Functional programming - a simple command line framework, a built-in function lines to split a text string on line boundaries, infix functions, working with lists, how to think about loops, anonymous (lambda) functions, partial function application and currying, as-patterns, and code reuse through composition
  • Writing a library: working with JSON data - develop a small, but complete, Haskell library
  • Using typeclasses - learn about the need for typeclasses and how to use them. The authors talk about defining their own typeclasses and then cover some of the important typeclasses that are defined in the Haskell library. Finally, the reader is showed how to have the Haskell compiler automatically derive instances ocf certain typeclasses for their types
  • Input and output - simple, standard-looking I/O, then discusses some of the more powerful options as well as provide more detail on how I/O fits into the pure, lazy, functional Haskell world
  • Efficient file processing, regular expressions, and file name matching
  • I/O case study: a library for searching the filesystem - develop a library that gives us many of find's capabilities, without leaving Haskell. The authors explore several different approaches to writing this library, each with different strengths
  • Code case study: parsing a binary data format
  • Testing and quality assurance - how to use QuickCheck to establish invariants in code and then re-examine the pretty printer developed in previous chapters, testing it with QuickCheck. The authors also see how to guide the testing process with GHC's code coverage tool: HPC
  • Barcode recognition - make use of the image parsing library developed in the code cast study to build a barcode recognition application
  • Data structures - looks at association lists, maps, and different data structures, with some extended examples
  • Monads - provide a powerful way to build computations with effects. This chapter illustrates how monads are useful tools to help solve practical problems
  • Programming with monads - including association lists, generalised lifting, and separating interface from implementation
  • The Parsec parsing library - a useful parser combinator library, with which we combine small parsing functions to build more sophisticated parsers
  • The foreign function interface - shows how the FFI adds a new dimension of flexibility to the language
  • Monad transformers - similar to a regular monad, but it's not a standalone entity: instead, it modifies the behaviour of an underlying monad
  • Error handling - in Haskell, you will find two major types of error handling employed: "pure" error handling and exceptions
  • Systems programming - attempts a Perl-like "language" that is valid Haskell, implemented in pure Haskell, that makes shell scripting easy
  • Working with databases - introduces the reader to one of the Haskell frameworks for working with databases. The authors also use this framework to begin building a podcast downloader
  • Web client programming - develop a real application in this chapter: a podcast downloader, or "podcatcher"
  • GUI programming - looks at gtk2hs, one of several graphical user interface toolkits available for Haskell
  • Basic concurrent and parallel programming - harness the power of multicore systems via concurrent and parallel programming
  • Profiling and tuning for performance - looks at typical space and time problems a Haskell programmer might encounter, and how to methodically analyse, understand and address them
  • Advanced library design: building a Bloom filter - a set-like data structure that is highly efficient in its use of space
  • Network programming - discusses lower-level networking tools in the Haskell library
  • Software transactional memory

This work is licensed under a Creative Commons Attribution-Noncommercial 3.0 License.

</td> </tr> </tbody> </table>

2. Developing Web Applications with Haskell and Yesod

优秀的Haskell图书
Website www.yesodweb.com/book
Author Michael Snoyman
Format HTML
Pages 298

Developing Web Applications with Haskell and Yesod is a guide which introduces web application development with Haskell and Yesod, a potent language/framework combination that supports high-performing applications that are modular, type-safe, and concise. The reader works with several samples to explore the way Yesod handles widgets, forms, persistence, and RESTful content. The reader also receives an introduction to various Haskell tools to supplement basic knowledge of the language.

After completing the book, the reader will have created a production-quality web application with Yesod’s ready-to-use scaffolding. Real-world examples, including a blog, a wiki, a JSON web service, and a Sphinx search server will have been examined.

Chapters cover:

  • Introduction - examines how Yesod aims to make web development easier by playing to the strengths of Haskell
  • Haskell - fills in some of the features of Haskell that are not covered in most introductory texts
  • Basics - gets the reader started with a simple Yesod application, and cover some of the basic concepts and terminology
  • Shakespearean Templates - use Shakespearean template languages for HTML, CSS, and Javascript output
  • Widgets - provide the glue that allows templates languages to work together. The chapter helps the reader understand how to construct and combine widgets, generate IDs, and understand type signatures
  • Yesod Typeclass - explores the meaning of many of the methods of the Yesod typeclass
  • Routing and Handlers - examines route syntax, pieces, types of pieces (static, dynamic single and dynamic multi), resource name, handler specification, dispatch, return type, arguments, the handler monad, application information, request information, short circuiting, and response headers
  • Forms - a way to validate data
  • Sessions & Persistent - learn how Yesod and Haskell store session data and handle persistence
  • Deploying your Webapp - build a simple application to learn Yesod’s foundation datatype and Web Application Interface (WAI)
  • Advanced:
    • RESTful Content - request methods: GET, POST, PUT, DELETE, representations, RepHtmlJson, news feeds, other request headers, stateless
    • Yesod's Monads - monad transformers, the three transformers, example: database-driven navbar, example: request information
    • Authentication and Authorization - authentication deals with identifying a user, authorization determines what a user is allowed to do
    • Scaffolding and the Site Template
    • Internationalization
    • Creating a Subsite - a collection of routes and their handlers that can be easily inserted into a master site. Create reusable components for several applications with Yesod subsites
  • Examples
    • Blog: i18n, authentication, authorization, and database
    • Wiki: markdown, chat subsite, event source
    • JSON Web Service
    • Case Study: Sphinx-based Search
    </ul> </td> </tr> </tbody> </table>

    3. Learn You a Haskell for Great Good!

    优秀的Haskell图书
    Website learnyouahaskell.com
    Author Miran Lipovača
    Format HTML
    Pages 376

    Learn You a Haskell for Great Good! is an illustrated guide to this complex functional language. Packed with the author's original artwork, pop culture references, and most importantly, useful example code, this book teaches functional fundamentals in a way you never thought possible.

    Chapters cover:

    • Introduction
    • Starting Out - includes an introduction to lists, texas ranges, and tuples
    • Types and Typeclasses - understanding the type system
    • Syntax in Functions - explores some of Haskell's constructs including pattern matching and let bindings
    • Recursion - takes a closer look at recursive functions, why they are important to Haskell and how we can work out very concise and elegant solutions to problems by thinking recursively
    • Higher-Order Functions - curried functions, maps and filters, lambdas, the foldl and foldr functions, the foldl1 and foldr1 functions, and the scanl and scanr functions, function application with $, function composition
    • Modules - a Haskell module is a collection of related functions, types and typeclasses. The chapter examines loading modules, Data.List, Data.Char, Data.Map, Data.Set, and making your own modules
    • Making Our Own Types and Type Classes - learn how to make your own Haskell types and typeclasses
    • Input and Output - examines files and streams, command line arguments, randomness, bytestrings and exceptions
    • Functionally Solving Problems - takes a look at a few interesting problems and how to think functionally
    • Functors, Applicative Functors and Monoids - takes a closer look at functors, along with slightly stronger and more useful versions of functors called applicative functors. The reader also explores monoids
    • A Fistful of Monads - learn about monads, which are beefed up applicative functors, much like applicative functors are beefed up functors
    • For a Few Monads More - learn about a few other monads. See how they can make programs clearer by letting us treat all sorts of values as monadic ones
    • Zippers - see how we can take some data structure and focus on a part of it in a way that makes changing its elements easy and walking around it efficient
    </td> </tr> </tbody> </table>

    4. Write Yourself a Scheme in 48 Hours

    优秀的Haskell图书
    Website en.wikibooks.org/wiki/Write_Yourself_a_Scheme_in_48_Hours
    Author Wikibooks contributors
    Format PDF, HTML
    Pages 138

    Write Yourself a Scheme in 48 Hours starts off with command-line arguments and parsing, and progresses to writing a fully-functional Scheme interpreter that implements a good-sized subset of R5RS Scheme. Along the way, the reader learns Haskell's I/O, mutable state, dynamic typing, error handling, and parsing features. By the end of the book, the reader should be fairly fluent in both Haskell and Scheme.

    Chapters cover:

    • Overview
    • First Steps: Compiling and running
    • Parsing
      1. A Simple Parser - using the Parsec library
      2. Whitespace - add a series of improvements to the simple parser that will let it recognize progressively more complicated expressions
      3. Literal Numbers and Strings: Return Values - learn how to define a data type, and how to modify our parser so that it returns this data type
      4. Lists, Dotted Lists, and Quoted Data: Recursive Parsers - add a few more parser actions to the interpreter
    • Evaluation, Part 1
      1. Displaying Values: Show and Typeclasses - the first steps towards a working Scheme interpreter: assigning values to program fragments
      2. Evaluating Primitive Values: Pattern Matching
      3. Evaluating Primitive Functions: First-class Functions - adding basic primitives
    • Intermezzo: Error Checking & Exceptions
    • Evaluation, Part 2 - additional primitives: partial application, conditionals: pattern matching 2, list primitives: car, cdr, and cons, equal? and weak typing: heterogenous lists
    • Building a REPL: Basic I/O - build a system that can execute multiple statements without exiting the program
    • Adding Variables and Assignment: Mutable State in Haskell
    • Defining Scheme Functions: Closures and Environments - define your own functions within Scheme and use them from other functions
    • Creating IO Primitives: File I/O
    • Towards a Standard Library: Fold and Unfold - implement two primitive recursion operators (fold and unfold) and then define our whole library based on those
    • Conclusion & Further Resources
    </td> </tr> </tbody> </table>

    5. The Haskell School of Music -- From Signals to Symphonies

    优秀的Haskell图书
    Website haskell.cs.yale.edu/euterpea-2/haskell-school-of-music/
    Author Paul Hudak
    Format PDF
    Pages 353

    The Haskell School of Music -- From Signals to Symphonies (a work in progress) is a book that describes Euterpea, a computer music library developed in Haskell. The library allows programming computer music applications both at the note level and the signal level.

    • An Overview of Computer Music, Euterpea, and Haskell - introduces some of the fundamental ideas of functional programming in Haskell
    • Simple Music - reveals the actual definitions of Euterpea’s functions and operators, such as note, rest,(:+:),(:=:), and trans. In addition, a number of other musical ideas are developed, and in the process more Haskell features are introduced
    • Polymorphic and Higher-Order Functions - covers abstraction over recursive definitions, append, fold, reversing a list, currying, and errors
    • A Musical Interlude - an existing composition is transcribed into Euterpea. Then a simple form of algorithmic composition is presented
    • Syntactic Magic - introduces several more of Haskell’s syntactic devices that facilitate writing concise and intuitive programs. It covers sections, anonymous functions, list comprehensions, function composition, higher-order thinking, and infix function application
    • More Music - explores a number of simple musical ideas, and contributes to a growing collection of Euterpea functions for expressing those ideas
    • Qualified Types - introduces the notions of qualified types and type classes
    • Interpretation and Performance - abstract performance, players, and putting it all together
    • Self-Similar Music - explores the notion of self-similar music — i.e. musical structures that have patterns that repeat themselves recursively in interesting ways
    • Proof by Induction - studies a powerful proof technique based on mathematical induction
    • An Algebra of Music - explores a number of properties of the Music data type and functions defined on it, properties that collectively form an algebra of music
    • Musical L-Systems - generative grammars, a simple implementation, grammars in Haskell, and an L-System grammar for music
    • Random Numbers, Probability Distributions, and Markov Chains - explores several sources of random numbers and how to use them in generating simple melodies
    • From Performance to MIDI - describes how to convert an abstract performance into a standard Midi file that can be played on any modern PC with a standard sound card
    • Basic Input/Output - expands on the play function
    • Musical User Interface - describes an elegant way to do IO involving a "musical user interface," or MUI
    • Sound and Signals - studies the fundamental nature of sound and its basic mathematical representation as a signal. The chapter also discusses discrete digital representations of a signal
    • Euterpea’s Signal Functions - shows how the theoretical concepts involving sound and signals studied in the last chapter are manifested in Euterpea
    • Spectrum Analysis - discusses the theory as well as the pragmatics for doing spectrum analysis in Euterpea
    • Additive Synthesis - add signals (usually sine waves of differing amplitudes, frequencies and phases) together to form a sound of interes
    </td> </tr> </tbody> </table>

    6. Yet Another Haskell Tutorial

    优秀的Haskell图书
    Website en.wikibooks.org/wiki/Haskell/YAHT
    Author Hal Daume III
    Format HTML, PDF
    Pages 192

    Yet Another Haskell Tutorial provides a complete introduction to the Haskell programming language. It assumes no knowledge of the Haskell language or familiarity with functional programming in general.

    Chapters cover:

    • Introduction
    • Getting Started
    • Language Basics - presents the basic concepts of Haskell and the basic syntax of Haskell
    • Type Basics - uses a system of static type checking. This means that every expression in Haskell is assigned a type
    • Basic Input/Output
    • Modules - program subcomponents are divided into modules
    • Advanced Features - examines sections and infix operators, local declarations, partial application, pattern matching, guards, instance declarations, datatypes revisited, more lists, arrays, maps, layout, and the final word on lists
    • Advanced Types - type synonyms, newtypes, datatypes, classes, instances, kinds, class hierarchies, and default
    • Monads - program subcomponents are divided into modules
    • Advanced Techniques
    </td> </tr> </tbody> </table>

    7. Parallel and Concurrent Programming in Haskell

    优秀的Haskell图书
    Website community.haskell.org/~simonmar/par-tutorial.pdf
    Author Simon Marlow
    Format PDF
    Pages 71

    Parallel and Concurrent Programming in Haskell introduces the main programming models available for concurrent and parallel programming in Haskell. This tutorial takes a deliberately practical approach: most of the examples are real Haskell programs that you can compile, run, measure, modify and experiment with.

    Chapters cover:

    • Parallel programming with the Eval monad
    • Evaluation Strategies
    • Dataow parallelism with the Par monad
    • Basic Concurrent Haksell
    • Asynchronous exceptions
    • Software Transactional Memory
    • Concurrency and the Foreign Function Interface
    • High-speed concurrent servers

    In order to follow this tutorial you should have a basic knowledge of Haskell, including programming with monads.

    </td> </tr> </tbody> </table>

    8. A Gentle Introduction to Haskell Version 98

    优秀的Haskell图书
    Website www.haskell.org/tutorial
    Author Paul Hudak, John Peterson, Joseph Fasel
    Format HTML, Postscript, PDF, gzipped PDF, DVI, HTML, Haskell source code
    Pages 64

    A Gentle Introduction to Haskell Version 98 is intended to serve as a supplement to the Haskell Report. The authors aim to offer a general introduction to Haskell for anyone who has some experience of another language.

    Chapters cover:

    • Introduction
    • Values, Types, and Other Goodies - all computations are done via the evaluation of expressions (syntactic terms) to yield values
    • Functions - looks at several aspects of functions in Haskell
    • Case Expressions and Pattern Matching - looks at the pattern-matching process in greater detail
    • Type Classes and Overloading
    • Types, Again - examines some of the more advanced aspects of type declarations
    • Input/Output - the I/O system in Haskell is purely functional, yet has all of the expressive power found in conventional programming languages
    • Standard Haskell Classes - introduces the predefined standard type classes in Haskell
    • Monads - addresses not only the language features that involve monads but also tries to reveal the bigger picture: why monads are such an important tool and how they are used
    • Numbers - Haskell provides a rich collection of numeric types, based on those of Scheme, which in turn are based on Common Lisp
    • Modules - serves the dual purpose of controlling name-spaces and creating abstract data types
    • Typing Pitfalls - gives an intuitive description of a few common problems that novices run into using Haskell's type system
    • Arrays - index types, array creation, accumulation, incremental updates, and an example: matrix multiplication
    </td> </tr> </tbody> </table>

    9. Haskell

    优秀的Haskell图书
    Website en.wikibooks.org/wiki/Haskell
    Author Wikibooks.org
    Format PDF, HTML, e-Book Reader optimized PDF
    Pages 597

    The aim of this book is to introduce the reader to both the Haskell language and to computer programming in general. The book covers all stages, from the very basics to the most advanced features of Haskell. It is divided into 3 sections: The Beginner's Track, the Advanced Track, and Practical Haskell.

    Beginner's Track

    The first section introduces the reader to the very basics of the language and some of the more frequently used libraries.

    • Haskell Basics:
      • Getting set up - explore how to install the programs you will need to start coding in Haskell
      • Variables and functions - keep track of intermediate results. A function takes an argument value (or parameter) and gives a result value, like a variable, that takes its place
      • Truth values - equality and other comparisons, boolean values, introduction to types, infix operators, boolean operations, and guards
      • Type basics - Types in programming are a way of grouping similar values into categories. In Haskell, the type system is a powerful way of ensuring there are fewer mistakes in your code
      • Lists and tuples - the two most fundamental ways of manipulating several values together, by grouping them into a single value
      • Type basics II - the num class, numeric types, and classes beyond numbers
      • Building vocabulary - discusses the importance of acquiring a vocabulary of functions and how this book, along with other resources, can help you with that
      • Next steps - introduces pattern matching, if expressions and let bindings
      • Simple input and output - actions, and actions under the microscope
    • Elementary Haskell:
      • Recursion - a form of repetition, looks at numeric recursion, other recursive functions, and list-based recursion
      • More about lists - rebuilding lists, generalizing, the map function, tips and tricks
      • List processing - folds, scans, filter, and list comprehensions (a powerful, concise and expressive syntactic construct)
      • Type declarations - data and constructor functions, deconstructing types, and type for making type synonyms
      • Pattern matching - takes a deeper look at pattern matching
      • Control structures - introduces a new control structure, case expressions
      • More on functions - let and where revisited, anonymous functions - lambdas, operators and sections
      • Higher order functions and Currying - Higher-order functions are functions that take other functions as arguments. Currying is a technique that lets you partially apply a multi-parameter function
      • Using GHCi effectively - describes several ways that GHCi can make you work faster
    • Intermediate Haskell:
      • Modules - Haskell modules are a useful way to group a set of related functionalities into a single package and manage a set of different functions that have the same name
      • Indentation - helps the reader to get a grip with the indentation rules
      • More on datatypes - enumerations, named fields (record syntax), and parameterized types
      • Other data structures - trees, and other datatypes
      • Classes and types - see how to define and implement type classes, and how to use them to our advantage
      • The Functor class - introduces the very important Functor class, use it as a simple example of how type classes can be useful tools for solving problems in a more general way
    • Monads:
      • Understanding monads - introduces the basic notions with the example of the Maybe monad, the simplest monad for handling exceptions
      • The Maybe monads - represents computations which might "go wrong", in the sense of not returning a value
      • The List monad - taken as monads, lists are used to model nondeterministic computations which may return an arbitrary number of result
      • do Notation
      • The IO monad - solves some problems for Haskell having simple input/output
      • The State monad - introduced to allow states of any complexity to be represented
      • Additive monads (MonadPlus) - defines two methods. mzero is the monadic value standing for zero results; while mplus is a binary function which combines two computations
      • Monadic parser combinators - Monads provide a clean means of embedding a domain specific parsing language directly into Haskell without the need for external tools or code generators
      • Monad transformers - special types that allow us to roll two monads into a single one that shares the behaviour of both
      • Practical monads - parsing monads and generic monads
      </ul>

      Advanced Track

      This section introduces wider functional programming concepts such as different data structures and type theory. It also covers more practical topics like concurrency.

      • Advanced Haskell:
        • Arrows - a generalization of monads: every monad gives rise to an arrow, but not all arrows give rise to monads
        • Understanding arrows - presents arrows from the perspective of stream processors, using the factory metaphor from the monads module as a support
        • Continuation passing style (CPS) - a format for expressions such that no function ever returns, instead they pass control onto a continuation
        • Zippers - Theseus and the Zipper, differentiation of data types
        • Applicative Functors - functors with some extra properties, the most important one is that it allows you to apply functions inside the functor (hence the name) to other values
        • Monoids - a more detailed look into monoids and the monoid type class
        • Mutable objects - discusses advanced programming techniques for using imperative constructs, such as references and mutable arrays, without compromising (too much) purity
        • Concurrency - in Haskell is mostly done with Haskell threads
      • Fun with Types:
        • Polymorphism basics - parametric polymorphism, the forall keyword, example: heterogeneous lists, explaining the term existential, and example: runST
        • Advanced type classes - multi-parameter type classes, functional dependencies, and examples
        • Phantom types - a way to embed a language with a stronger type system than Haskell's
        • Generalised algebraic data-types (GADT) - allows you to explicitly write down the types of the constructors. This chapter explains why this is useful and how to declare them
        • Type constructors & Kinds
      • Wider Theory:
        • Denotational semantics - explains how to formalize the meaning of Haskell programs, the denotational semantics
        • Category theory - gives an overview of category theory, in so far as it applies to Haskel
        • The Curry-Howard isomorphism - a striking relationship connecting two seemingly unrelated areas of mathematics — type theory and structural logic
        • fix and recursion
      • Haskell Performance:
        • Introduction - execution model, algorithms & data structures, and parallelism
        • Step by Step Examples
        • Graph reduction - evaluating expressions by lazy evaluation, controlling space, reasoning about time, and implementation of graph reduction
        • Laziness
        • Strictness - difference between strict and lazy evaluation, why laziness can be problematic
        • Algorithm complexity
        • Data structures
        • Parallelism
        </ul>

        Haskell in Practice:

        This section covers the more day-to-day issues of working with Haskell, issues such as making use of the standard library, building graphical interfaces or working with databases.

        Topics cover: