regular-web: Generic programming for the web

[ bsd3, generics, library, web ] [ Propose Tags ]

This package implements generic functions for web programming. Based on the regular library [1], we provide generic functions for generating HTML, Formlets, and JSON. For a larger example, see the Example.lhs [2] file on github.

  1. http://hackage.haskell.org/package/regular

  2. http://github.com/chriseidhof/regular-web/blob/master/Example.lhs

Example

Consider the following datatypes:

data Person = Person {
    _name   :: String
  , _age    :: Int
  , _isMale :: Bool
  , _place  :: Place
  }
data Place = Place {
    _city      :: String
  , _country   :: String
  , _continent :: String
}

We can now derive a Regular instance for the Person datatype using Template Haskell:

$(deriveAll ''Place  "PFPlace")
$(deriveAll ''Person "PFPerson")
type instance PF Place  = PFPlace
type instance PF Person = PFPerson

We can construct an example person:

location :: Place
location = Place "Utrecht" "The Netherlands" "Europe"
chris    :: Person
chris    = Person "chris" 25 True location
And, as an example, we can generate |HTML| and |JSON| values:
locationHtml :: X.Html
locationHtml = ghtml location
personHtml :: X.Html
personHtml = ghtml chris
locationJSON :: JSValue
locationJSON = gto location

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1, 0.1.1
Dependencies applicative-extras, base (>=4 && <5), fclabels (>=0.4.2), formlets (==0.6.1), json (>=0.4.3), mtl, regular (>=0.1.0.2), xhtml [details]
License BSD-3-Clause
Copyright (c) Chris Eidhof
Author Chris Eidhof
Maintainer Chris Eidhof <chris+hackage@eidhof.nl>
Category Generics, Web
Home page http://github.com/chriseidhof/regular-web
Uploaded by ChrisEidhof at 2010-03-20T16:13:42Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1816 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]