The latest version of regular-web is 0.1.1-0.
regular-web
Version 0.1 revision 0 uploaded by ChrisEidhof.
Package meta
- Synopsis
- Generic programming for the web
- Description
This package implements generic functions for web programming. Based on the
regular
library [1], we provide generic functions for generatingHTML
,Formlets
, andJSON
. For a larger example, see theExample.lhs
[2] file on github.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 thePerson
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
- Author
- Chris Eidhof
- Bug reports
- n/a
- Category
- Generics, Web
- Copyright
- (c) Chris Eidhof
- Homepage
- http://github.com/chriseidhof/basil
- Maintainer
- Chris Eidhof <chris+hackage@eidhof.nl>
- Package URL
- n/a
- Stability
- n/a