Features Download
From: Niklas Broberg <niklas.broberg <at> gmail.com>
Subject: ANNOUNCE: Haskell Server Pages v 0.4
Newsgroups: gmane.comp.lang.haskell.cafe
Date: Tuesday 25th March 2008 19:33:36 UTC (over 9 years ago)
Greetings fellow Haskelleers,

I am very pleased to announce a new chapter in the Haskell Server
Pages saga. After a two-year long hiatus, while we in the team have
been busy with Other Stuff, we have resumed work on Project HSP, and
this release marks the first milestone.

===  Project HSP  ===

Haskell Server Pages (HSP) is a programming model for writing dynamic
web pages in Haskell, both server-side and client-side. One of its
core features is the use of literal XML syntax mixed with ordinary
Haskell code.

* Project HSP home (with bug/feature tracker): http://code.google.com/p/hsp
* Project HSP mailing list: [email protected]
* Project HSP darcs repos: http://code.haskell.org/HSP

For flavor, here is a simple Hello World application written in HSP:
module HelloWorld where

import HSP
import HSP.HJScript
import HJScript
import HJScript.DOM

-- A simple HTML page holding a button with onClick action.
page :: HSP XML
page =
      Hello World
      <%  `onClick`
           (window # alert (string "Hello World !")) %>

Note that literal XML elements are first class expressions in HSP,
unlike languages like PHP. Also note that using literal XML syntax is
by no means required, if you don't feel like writing the XML manually
(I sure don't!). There are combinators for building XHTML pages
(although they are currently missing from version 0.4, will be added
shortly, but release early and all that...).

The most interesting new feature in version 0.4 is that literal XML
syntax (or the equivalent combinators) can now be used to create XML
elements both server-side and client-side, with the same code. Here is
another short example script showing this feature:
module AddParagraph where

import HJScript hiding (test)
import HJScript.DOM
import HSP
import HSP.HJScript

makeP x = 

<% x %>

page :: HSP XML page = Add paragraph <% do (r,b) <- ref <% makeP "Paragraph created Server-side!" %> let fun = do let x = document # getElementById (string r) x <: makeP "Paragraph created Client-side!" return () b <: ( `onClick` fun) %> -------------------- Project HSP v 0.4 consists of a set of packages with related functionality: == package hsx == Haskell Source with XML (HSX, hsx) is a package that contains everything pertaining to literal XML syntax. In particular it contains a) the trhsx preprocessor that translates hsx source files into vanilla Haskell, and b) modules defining the functions that are injected by trhsx. It also nominally contains generic combinators for creating values of the same types as the literal XML syntax, though these modules are not present in 0.4. darcs get --partial http://code.haskell.org/HSP/hsx http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsx-0.4 == package hsp == The core HSP package defines the datatypes and functions for writing server-side dynamic web pages. Also defines how to use the HJScript functionality in HSP pages, to allow for client-side dynamics as well. darcs get --partial http://code.haskell.org/HSP/hsp http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsp-0.4 == package HJavaScript == This package defines an abstract syntax and (not-so-)pretty printer for a large subset of JavaScript, as Language.HJavaScript. However, a significant difference from JavaScript is that HJavaScript is typed, even on the abstract syntax level using GADTs. The subset of JavaScript that is supported is those parts that lend themself to typing (i.e. no prototyping of classes). darcs get --partial http://code.haskell.org/HSP/hjavascript http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HJavaScript-0.4 == package HJScript == HJScript is a DSL built on top of HJavaScript, for writing client-side dynamic web pages. The programming model is fairly low-level, resembling the actual JavaScript code quite a lot, but should be easy to extend with higher-level functionality. Notable is that HJScript supports the use of literal XML syntax for creating DOM ElementNodes. Also notable is that HJScript supports Ajax functionality. HJScript and HJavaScript can be used independently of HSP, for creating JavaScript code. darcs get --partial http://code.haskell.org/HSP/hjscript http://hackage.haskell.org/cgi-bin/hackage-scripts/package/HJScript-0.4 == package hsp-cgi == Run HSP pages as CGI scripts. darcs get --partial http://code.haskell.org/HSP/hsp-cgi http://hackage.haskell.org/cgi-bin/hackage-scripts/package/hsp-cgi-0.4 (Note: Earlier versions of HSP have come with a server application, hspr, providing the runtime environment for HSP. As of 0.4, this server has been discontinued and should be considered deprecated.) ===================== Notable items on the TODO list for Project HSP: - More functionality, allowing for higher-level programming models. - Writing larger applications, in order to stress test, and serve as inspiration for higher-level functionality. - Integrate with HAppS, to allow stateful computation (among other things). - A home on the web for HSP, with a web page written in HSP. We welcome both users (of course) and contributors to the project. There is much work to be done, and we welcome all help we can get. If you think this is interesting stuff, drop by our mailing list ([email protected]). Like to do web programming in Haskell? Want to do a GSoC project? We in the project would be happy to see applications for HSP projects, and the list above is a good starting place. See for instance (http://hackage.haskell.org/trac/summer-of-code/ticket/1538) and (http://hackage.haskell.org/trac/summer-of-code/ticket/1539). Cheers, /Niklas on behalf of the Project HSP team
CD: 3ms