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
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
《军事政治学研究(2015年第2辑/总第10辑)》内容简介:《军事政治学研究》是由中国人民解放军南京政治学院军事政治学研究中心创办
《拿笔就画!色铅笔绘画从入门到精通》内容简介:拿笔就画!许多人都期望能够随心所欲地勾画我们看到的世界和想象的世界,《拿笔就
本书首先通过“总体架构”梳理了各个模块的分类、功能和依赖关系,让大家对jQuery的工作原理有大致的印象;进而通过“构造jQuery
《森林里的调皮猴》内容简介:“谭旭东乐享慢读系列”收录了著名儿童文学作家谭旭东的数篇优秀佳作,包括儿童诗、童话、散文三个体
Thepurposeofthisbookistohelpyouunderstandhowtoprogramshared-memoryparallelmachin...
这是一本为网页设计师量身定制的配色方案专业书籍。全书共分七个部分,分别结合丰富的实例讲述了配色基础知识、色相和色调(Hue&
《第三代移动通信网络系统技术应用及演进》涵盖了现代移动通信,主要是第三代移动通信(3G、E3G和B3G,简称3G)主流技术的基本理
为了彻底理解是什么使得Linux能正常运行以及其为何能在各种不同的系统中运行良好,你需要深入研究内核最本质的部分。内核处理CPU
《元代辽阳行省女真人研究》内容简介:本书对元代辽阳行省女真人进行全景式系列研究。书中将元代辽阳行省女真人分成北部、东部、南
本书从不同的视角介绍了Node内在的特点和结构。由首章Node介绍为索引,涉及Node的各个方面,主要内容包含模块机制的揭示、异步I/
WordPress爱好者的福音,由WordPress团队的美女成员LisaSabin-Wilson编著的WordPressForDummies(WordPres...
Java是目前应用最为广泛的软件开发平台,学习针对Java程序的优化方法有重要的现实意义。《Java程序性能优化:让你的Java程序更快
《黑客攻防从入门到精通:黑客与反黑客工具篇(第2版)》内容简介:本书从“攻”“防”两个不同的角度出发,在讲解黑客攻击手段的同
《从零开始学HTML+CSS》分为3篇,共12章。第1篇是HTML基础(第1~2章),第2篇是HTML应用篇(第3~10章),第3篇是CSS的使用(第
《TensorFlow机器学习实战指南(原书第2版)》内容简介:本书由资深数据科学家撰写,从实战角度系统讲解TensorFlow基本概念及各种应
《ActionScript3.0精彩范例词典》列出了最常用的ActionScript语法,并附有详细的程序代码范例,不但教您如何使用、修改ActionScr
Imageware 逆向造型技术及3D打印-(含光盘1张) 本书特色 imageware被誉为全球四大知名逆向造型软件之一,具有强大的逆向造型功能,在国内外已得...
《战后世界进程与外国文学进程研究(第三卷):全球化视域下的当代外国文学研究》内容简介:20世纪80年代以来,全球化与反全球化两
DjangoandTurbogearsarethetwoleadingMVCframeworksforPythonprogrammerstoday.MVCfra...
内容介绍:文字在浩涉的文明岁月中幻化出千姿百态,于是,才会有这本文字美丽的书。从书中,也许你可读出一部中国文字美丽的历史