Developing Web Applications with Haskell and Yesod Buy on Amazon

https://www.ebooknetworking.net/books_detail-1449316972.html

Developing Web Applications with Haskell and Yesod

30.10 34.99 USD
Buy New on Amazon 🇺🇸 Buy Used — $0.15

Usually ships in 24 hours

Book Details

ISBN / ASIN1449316972
ISBN-139781449316976
AvailabilityUsually ships in 24 hours
Sales Rank1,498,432
MarketplaceUnited States  🇺🇸

Description


Five Great Tips for Developing Web Apps with Haskell & Yesod

1. Haskell makes it easy to create new datatypes. Instead of reusing Int for year, month, and day, you can create one- line newtype wrappers, and the compiler will prevent you from accidentally mixing them up. So you can have code that looks like: newtype Year = Year Int
newtype Month = Month Int
newtype Slug = Slug Text getBlogPostR :: Year -> Month -> Slug -> Handler RepHtml 2. Yesod uses third-party authentication out of the box. The BrowserID and Google Email plugins allow you to authenticate users via their email address, without forcing them to create a new password just for your site. It also removes the burden from your app of validating their ownership of the address in question. And, if in the future you want to have logins from your site, it's easy to transition to the email/password backend.

3. It's recommended to avoid overlapping routes whenever possible. Yesod will warn you if two routes could both match the same requested URL. However, if you really want to do this, use the special exclamation mark syntax: /blog/!2008 Blog2008ArchiveR GET
/blog/#Year BlogArchiveR GET Don't forget that when you have overlapping routes, order matters! The first route in the list that matches will be used.

4. Lazy I/O can be a simple and convenient way to read in large files. However, on a busy server, this could end up using too many file descriptors. Instead, it's best to use conduit, which has deterministic resource handling. Reading a file, compressing it, and writing it back out is as simple as: sourceFile "input" $$ gzip =$ sinkFile "output"
5. Sending data to and from the client via JSON is highly recommended. The yesod-json packages provides jsonToRepJson and parseJsonBody for this purpose. Combined with some powerful client-side Javascript frameworks, you can easily create rich client-side applications.

Donate to EbookNetworking
Prev
Next