Cover image for Developing Web Applications with Haskell and Yesod

Book description

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.

Table of Contents

  1. Developing Web Applications with Haskell and Yesod
  2. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  3. Preface
    1. Who This Book Is For
    2. Conventions Used in This Book
    3. Using Code Examples
    4. Safari® Books Online
    5. How to Contact Us
    6. Acknowledgements
  4. I. Basics
    1. 1. Introduction
      1. Type Safety
      2. Concise
      3. Performance
      4. Modular
      5. A Solid Foundation
      6. Introduction to Haskell
    2. 2. Haskell
      1. Terminology
      2. Tools
      3. Language Pragmas
      4. Overloaded Strings
      5. Type Families
      6. Template Haskell
      7. QuasiQuotes
      8. Summary
    3. 3. Basics
      1. Hello World
      2. Routing
      3. Handler Function
      4. The Foundation
      5. Running
      6. Resources and Type-Safe URLs
      7. The Scaffolded Site
      8. Development Server
      9. Summary
    4. 4. Shakespearean Templates
      1. Synopsis
        1. Hamlet (HTML)
        2. Cassius (CSS)
        3. Lucius (CSS)
        4. Julius (JavaScript)
      2. Types
        1. Type-Safe URLs
      3. Syntax
        1. Hamlet Syntax
          1. Tags
          2. Interpolation
          3. Attributes
          4. Conditionals
          5. Maybe
          6. Forall
          7. Case
          8. With
          9. Doctype
        2. Cassius Syntax
        3. Lucius Syntax
        4. Julius Syntax
      4. Calling Shakespeare
        1. Alternate Hamlet Types
      5. Other Shakespeare
      6. General Recommendations
    5. 5. Widgets
      1. Synopsis
      2. What’s in a Widget?
      3. Constructing Widgets
      4. Combining Widgets
      5. Generate IDs
      6. whamlet
        1. Types
      7. Using Widgets
      8. Summary
    6. 6. Yesod Typeclass
      1. Rendering and Parsing URLs
        1. joinPath
        2. cleanPath
      2. defaultLayout
        1. getMessage
      3. Custom Error Pages
      4. External CSS and JavaScript
      5. Smarter Static Files
      6. Authentication/Authorization
      7. Some Simple Settings
      8. Summary
    7. 7. Routing and Handlers
      1. Route Syntax
        1. Pieces
          1. Types of Pieces
        2. Resource Name
        3. Handler Specification
      2. Dispatch
        1. Return Type
        2. Arguments
      3. The Handler Monad
        1. Application Information
        2. Request Information
        3. Short Circuiting
        4. Response Headers
      4. Summary
    8. 8. Forms
      1. Synopsis
      2. Kinds of Forms
      3. Types
      4. Converting
      5. Create AForms
        1. Optional Fields
      6. Validation
      7. More Sophisticated Fields
      8. Running Forms
      9. i18n
      10. Monadic Forms
      11. Input Forms
      12. Custom Fields
      13. Summary
    9. 9. Sessions
      1. Clientsession
      2. Controlling Sessions
      3. Session Operations
      4. Messages
      5. Ultimate Destination
      6. Summary
    10. 10. Persistent
      1. Synopsis
      2. Solving the Boundary Issue
        1. Types
        2. Code Generation
        3. PersistStore
      3. Migrations
      4. Uniqueness
      5. Queries
        1. Fetching by ID
        2. Fetching by Unique Constraint
        3. Select Functions
          1. SelectOpt
      6. Manipulation
        1. Insert
        2. Update
        3. Delete
      7. Attributes
      8. Relations
      9. Closer Look at Types
      10. Custom Fields
      11. Persistent: Raw SQL
      12. Integration with Yesod
      13. Summary
    11. 11. Deploying Your Webapp
      1. Compiling
      2. Warp
        1. Configuration
        2. Server Process
      3. FastCGI
      4. Desktop
      5. CGI on Apache
      6. FastCGI on lighttpd
      7. CGI on lighttpd
  5. II. Advanced
    1. 12. RESTful Content
      1. Request Methods
      2. Representations
        1. RepHtmlJson
        2. News Feeds
      3. Other Request Headers
      4. Stateless
      5. Summary
    2. 13. Yesod’s Monads
      1. Monad Transformers
      2. The Three Transformers
      3. Example: Database-Driven Navbar
      4. Example: Request Information
      5. Summary
    3. 14. Authentication and Authorization
      1. Overview
      2. Authenticate Me
      3. Email
      4. Authorization
      5. Conclusion
    4. 15. Scaffolding and the Site Template
      1. How to Scaffold
      2. File Structure
        1. Cabal File
        2. Routes and Entities
        3. Foundation and Application Modules
        4. Import
        5. Handler Modules
      3. widgetFile
      4. defaultLayout
      5. Static Files
      6. Conclusion
    5. 16. Internationalization
      1. Synopsis
      2. Overview
      3. Message Files
        1. Specifying Types
      4. RenderMessage Typeclass
      5. Interpolation
      6. Phrases, Not Words
    6. 17. Creating a Subsite
      1. Hello World
  6. III. Examples
    1. 18. Blog: i18n, Authentication, Authorization, and Database
    2. 19. Wiki: Markdown, Chat Subsite, Event Source
    3. 20. JSON Web Service
      1. Server
      2. Client
    4. 21. Case Study: Sphinx-Based Search
      1. Sphinx Setup
      2. Basic Yesod Setup
      3. Searching
      4. Streaming xmlpipe Output
      5. Full Code
  7. IV. Appendices
    1. A. monad-control
      1. Overview
      2. Intuition
      3. Types
        1. MonadTransControl
        2. MonadControlIO
      4. Real Life Examples
      5. Lost State
      6. More Complicated Cases
    2. B. Conduit
      1. Conduits in Five Minutes
      2. Structure of This Chapter
      3. The Resource Monad Transformer
        1. Goals
        2. How It Works
        3. Some Type Magic
        4. Definition of ResourceT
        5. Other Typeclasses
        6. Forking
        7. Convenience Exports
      4. Source
        1. State
        2. sourceState and sourceIO
      5. Sinks
        1. Types
        2. Sinks: no helpers
        3. Sinks: with Helpers
        4. List Functions
        5. Connecting
      6. Conduit
        1. Types
        2. Simple Conduits
        3. Stateful Conduits
        4. Using Conduits
        5. Data Loss
        6. SequencedSink
      7. Buffering
        1. Inversion of Control
          1. A web server
          2. Whither the request body?
        2. BufferedSource
        3. Typeclass
        4. Recapping the Web Server
    3. C. Web Application Interface
      1. The Interface
        1. Response Body
        2. Request Body
      2. Hello World
      3. Middleware
    4. D. Settings Types
    5. E. http-conduit
      1. Synopsis
      2. Concepts
      3. Request
      4. Manager
      5. Response
      6. http and httpLbs
    6. F. xml-conduit
      1. Synopsis
      2. Types
        1. The Four Types of Nodes
        2. Documents
        3. Events
      3. Text.XML
        1. A Note About File Paths
      4. Cursor
      5. xml-hamlet
      6. xml2html
  8. About the Author
  9. SPECIAL OFFER: Upgrade this ebook with O’Reilly