Online Book Reader

Home Category

Learn You a Haskell for Great Good! - Miran Lipovaca [184]

By Root 563 0
Back Up, Going Back Up, Focusing on Lists, Focusing on Lists, Focusing on Lists

defined, Going Back Up

filesystem example, Focusing on Lists

focus of, Going Back Up

for lists, Focusing on Lists

using with data structures, Focusing on Lists

zipWith function, Some Higher-Orderism Is in Order, Lambdas

About the Author

Miran Lipovaca is a computer science student in Ljubljana, Slovenia. His online tutorial, "Learn You a Haskell for Great Good!," is widely regarded as the best way to learn Haskell.

Colophon

The fonts used in Learn You a Haskell for Great Good! are New Baskerville, Futura, The Sans Mono Condensed and Dogma. The book was typeset with LATEX2ε package nostarch by Boris Veytsman (2008/06/06 v1.3 Typesetting books for No Starch Press).

This book was printed and bound by Transcontinental, Inc. at Transcontinental Gagné in Louiseville, Quebec, Canada. The paper is Domtar Husky 60# Smooth, which is certified by the Forest Stewardship Council (FSC). The book has an Otabind binding, which allows it to lie flat when open.

Appendix A. Updates

Visit http://www.nostarch.com/lyah.htm for updates, errata, and other information.

Table of Contents

Learn You a Haskell for Great Good!

Introduction

So, What's Haskell?

What You Need to Dive In

Acknowledgments

1. Starting Out

Calling Functions

Baby's First Functions

An Intro to Lists

Concatenation

Accessing List Elements

Lists Inside Lists

Comparing Lists

More List Operations

Texas Ranges

I'm a List Comprehension

Tuples

Using Tuples

Using Pairs

Finding the Right Triangle

2. Believe the Type

Explicit Type Declaration

Common Haskell Types

Type Variables

Type Classes 101

The Eq Type Class

The Ord Type Class

The Show Type Class

The Read Type Class

The Enum Type Class

The Bounded Type Class

The Num Type Class

The Floating Type Class

The Integral Type Class

Some Final Notes on Type Classes

3. Syntax in Functions

Pattern Matching

Pattern Matching with Tuples

Pattern Matching with Lists and List Comprehensions

As-patterns

Guards, Guards!

where?!

where's Scope

Pattern Matching with where

Functions in where Blocks

let It Be

let in List Comprehensions

let in GHCi

case Expressions

4. Hello Recursion!

Maximum Awesome

A Few More Recursive Functions

replicate

take

reverse

repeat

zip

elem

Quick, Sort!

The Algorithm

The Code

Thinking Recursively

5. Higher-Order Functions

Curried Functions

Sections

Printing Functions

Some Higher-Orderism Is in Order

Implementing zipWith

Implementing flip

The Functional Programmer's Toolbox

The map Function

The filter Function

More Examples of map and filter

Mapping Functions with Multiple Parameters

Lambdas

I Fold You So

Left Folds with foldl

Right Folds with foldr

The foldl and foldr1 Functions

Some Fold Examples

Another Way to Look at Folds

Folding Infinite Lists

Scans

Function Application with $

Function Composition

Function Composition with Multiple Parameters

Point-Free Style

6. Modules

Importing Modules

Solving Problems with Module Functions

Counting Words

Needle in the Haystack

Caesar Cipher Salad

On Strict Left Folds

Let's Find Some Cool Numbers

Mapping Keys to Values

Almost As Good: Association Lists

Enter Data.Map

Making Our Own Modules

A Geometry Module

Hierarchical Modules

7. Making Our Own Types and Type Classes

Defining a New Data Type

Shaping Up

Improving Shape with the Point Data Type

Exporting Our Shapes in a Module

Record Syntax

Type Parameters

Should We Parameterize Our Car?

Vector von Doom

Derived Instances

Equating People

Show Me How to Read

Order in the Court!

Any Day

Return Main Page Previous Page Next Page

®Online Book Reader