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
本书由浅入深、循序渐进地介绍了HTML、XHTML和CSS的语法、元素、属性的使用方法,介绍了如何使用(X)HTML和CSS编写符合标准的Web页
水下运载器操纵控制及模拟仿真技术 本书特色 《水下运载器操纵控制及模拟仿真技术》是由国防工业出版社出版的。水下运载器操纵控制及模拟仿真技术 内容简介 本书通过水...
所有程序员都知道应该做单元测试,但为什么你们没有做呢?是因为对单元测试不够了解,还是嫌单元测试麻烦,抑或认为单元测试的投
从光学电报到无绳电话,我们的交流关系是怎样形成的?这就是本书所试图回答的问题。在这本书中,帕特里斯•费里奇详细描述了第一批
《心若莲花处处开》内容简介:南怀瑾精研儒、释、道,将中国文化各种思想融会贯通,可谓一代宗师。在他眼里,儒、道、佛的经典学问
《半小时漫画理财课》内容简介:作为曾经月入3000元的“月光族”,理财师八宝用5年时间攒下了人生第一个1000万元;作为从海外归来的
《射频通信电路学习指导(第2版)》是普通高等教育“十五”国家级规划教材《射频通信电路》(第二版)的配套教辅书。《射频通信电路
《5分钟生物课》内容简介:你相信鱼在水中也憋气吗?你知道植物用什么“语言”进行交流吗?果子狸是SARS的“元凶”吗?植物真能防辐
从文化史料建设或者远距离窥视伟人私生活尤其是婚恋生活的角度,莎乐美与弗洛伊德等人的通信无疑具有非常重要的意义,同时也给本
《经学通论》内容简介:《经学通论》是清代经学大师皮锡瑞的代表作。皮氏娴于汉、宋家法,故举凡古、今宗派,以至清代诸家,皆能考
设计,使我们的生活变得生动有趣、丰富惬意,它时不时地把你卷入一个潮流中,再把你拉出来,推向另一个潮流。千万不要以为,是你
本书以独特的编辑理念展示了极具视觉冲击力的图像,这些作品既大气而又清晰准确地传达出它们所要表达的信息。本书集实用与艺术于
《移动通信频谱技术与5G频率部署》内容简介:无线电频谱是所有无线电业务的稀缺、关键资源。对移动运营商而言,频谱资源是网络建设
《藏在木头里的灵魂》内容简介:18世纪法国传教士笔下绝美中国建筑首次面世,完整重译十八世纪法文原版,体会深刻人文情怀与历史感
不同于以往任何时期,如今我们进入了大数据的信息时代。利用合适的工具,我们可以探索数据的价值和意义,挖掘数据背后的模式及其
《第一行代码——Android》是Android初学者的最佳入门书。全书由浅入深、系统全面地讲解了Android软件开发的方方面面。第1章带领
本书由微软资深企业架构师兼Kinect应用开发专家亲自执笔,既系统全面地讲解了Kinect技术的工作原理,又细致深入地讲解了Kinect交
《程履绎传》内容简介:雨花台烈士传丛书包括《李得钊传》《骆何民传》《许金元传》《蒋云传》《张应春传》《陈履真传》《刘重民传
网络工程师教程(第三版) 本书特色 《网络工程师教程》根据人力资源和社会保障部、工业和信息化部文件,计算机技术与软件专业技术资格(水平)考试纳入全国专业技术人员...
这是一部色彩理论和实际应用的通用指导,为艺术家和设计师提供一系列的色彩概念,条理清晰,简单易懂。斯蒂芬·潘泰克和理查德·