Michael Snoyman《Developing Web Applications with Haskell and Yesod》

Michael Snoyman《Developing Web Applications with Haskell and Yesod》

作者:Michael Snoyman

出版社:O'Reilly Media

出版年:2012-5-4

评分:7.2

ISBN:9781449316976

所属分类:网络科技

书刊介绍

内容简介

This fast-moving guide 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. You’ll work with several samples to explore the way Yesod handles widgets, forms, persistence, and RESTful content. You also get an introduction to various Haskell tools to supplement your basic knowledge of the language.

By the time you finish this book, you’ll create a production-quality web application with Yesod’s ready-to-use scaffolding. You’ll also examine several real-world examples, including a blog, a wiki, a JSON web service, and a Sphinx search server.

Build a simple application to learn Yesod’s foundation datatype and Web Application Interface (WAI)

Use Shakespearean template languages for HTML, CSS, and Javascript output

Produce cleaner, more modular code by learning how Yesod monads interact

Implement the yesod-form declarative API to build forms on top of widgets

Learn how Yesod and Haskell store session data and handle persistence

Use techniques to serve an HTML page and a machine-friendly JSON page from the same URL

Create reusable components for several applications with Yesod subsites

作品目录

Basics

Chapter 1 Introduction

Type Safety

Concise

Performance

Modular

A Solid Foundation

Introduction to Haskell

Chapter 2 Haskell

Terminology

Tools

Language Pragmas

Overloaded Strings

Type Families

Template Haskell

QuasiQuotes

Summary

Chapter 3 Basics

Hello World

Routing

Handler Function

The Foundation

Running

Resources and Type-Safe URLs

The Scaffolded Site

Development Server

Summary

Chapter 4 Shakespearean Templates

Synopsis

Types

Syntax

Calling Shakespeare

Other Shakespeare

General Recommendations

Chapter 5 Widgets

Synopsis

What’s in a Widget?

Constructing Widgets

Combining Widgets

Generate IDs

whamlet

Using Widgets

Summary

Chapter 6 Yesod Typeclass

Rendering and Parsing URLs

defaultLayout

Custom Error Pages

External CSS and JavaScript

Smarter Static Files

Authentication/Authorization

Some Simple Settings

Summary

Chapter 7 Routing and Handlers

Route Syntax

Dispatch

The Handler Monad

Summary

Chapter 8 Forms

Synopsis

Kinds of Forms

Types

Converting

Create AForms

Validation

More Sophisticated Fields

Running Forms

i18n

Monadic Forms

Input Forms

Custom Fields

Summary

Chapter 9 Sessions

Clientsession

Controlling Sessions

Session Operations

Messages

Ultimate Destination

Summary

Chapter 10 Persistent

Synopsis

Solving the Boundary Issue

Migrations

Uniqueness

Queries

Manipulation

Attributes

Relations

Closer Look at Types

Custom Fields

Persistent: Raw SQL

Integration with Yesod

Summary

Chapter 11 Deploying Your Webapp

Compiling

Warp

FastCGI

Desktop

CGI on Apache

FastCGI on lighttpd

CGI on lighttpd

Advanced

Chapter 12 RESTful Content

Request Methods

Representations

Other Request Headers

Stateless

Summary

Chapter 13 Yesod’s Monads

Monad Transformers

The Three Transformers

Example: Database-Driven Navbar

Example: Request Information

Summary

Chapter 14 Authentication and Authorization

Overview

Authenticate Me

Email

Authorization

Conclusion

Chapter 15 Scaffolding and the Site Template

How to Scaffold

File Structure

widgetFile

defaultLayout

Static Files

Conclusion

Chapter 16 Internationalization

Synopsis

Overview

Message Files

RenderMessage Typeclass

Interpolation

Phrases, Not Words

Chapter 17 Creating a Subsite

Hello World

Examples

Chapter 18 Blog: i18n, Authentication, Authorization, and Database

Chapter 19 Wiki: Markdown, Chat Subsite, Event Source

Chapter 20 JSON Web Service

Server

Client

Chapter 21 Case Study: Sphinx-Based Search

Sphinx Setup

Basic Yesod Setup

Searching

Streaming xmlpipe Output

Full Code

Appendices

Appendix monad-control

Overview

Intuition

Types

Real Life Examples

Lost State

More Complicated Cases

Appendix Conduit

Conduits in Five Minutes

Structure of This Chapter

The Resource Monad Transformer

Source

Sinks

Conduit

Buffering

Appendix Web Application Interface

The Interface

Hello World

Middleware

Appendix Settings Types

Appendix http-conduit

Synopsis

Concepts

Request

Manager

Response

http and httpLbs

Appendix xml-conduit

Synopsis

Types

Text.XML

Cursor

xml-hamlet

xml2html

相关推荐

微信二维码