úÎ1:/’     A . is responsible for maintaining the state for  sequences V for all users. To do this, it keeps for each user a session object encapsulating I their dialogs, and associates each user with a dialog using cookies. A  represents a single user'%s active dialogs, which are retained R for an entire session. A reaper thread clears up sessions that have not been S touched for some session timeout, so each session also stores the last time it V was touched. In addition, each session is associated with a fixed client address G and cannot be used from a different client, which avoid hijacking.  A value of > type represents a way of rendering a page, given a unique ID W that should be included in responses in order to reassociate the response with the  current dialog.  A value of a @ type represents a dialog between the user and the application, 7 after which the application builds a value of type a. The trivial case is that W the value is already known. Alternatively, it may be that there is some action to M be performed, or else that the user needs to be asked or told something. GConverts methods for rendering and parsing the result of a page into a   step. 3Determine whether a session is still valid or not. *Monadic while statement, for convenience.  Create a new 4 to manage a set of dialogs in the web application. L This also spawns the session reaper, which cleans up sessions that haven't been % touched for a given time period. LCloses a DialogManager, which will cause it to cease accepting any incoming ? requests, and also to terminate the session reaper thread. Given a < with a key type that can be randomly chosen, returns a key & that is not currently in the map. Adds a 6 and associated cookie. This always sets a new blank F session, so should only be used when there is no session already. Ensures that there is a ' for the current user, and returns it. T Adds a blank one if necessary. This also updates the last touched time for the P session, preventing it from being removed by the reaper thread for a while. The  function builds a " that handles a given dialog. In X general, it can be combined in normal ways with guards and such, so long as changes ! in the request parameters won'9t cause it to be missed when future requests are made in  the same dialog. The < type class represents data that can be included in a form. Q To make it easy to compose several of these in a page, rendering and parsing Q are parameterized with prefix strings so that they may be made unique across  a page. The  H function builds a user interaction to display and collect information. S In a finished web application, this should generally be replaced with a better S mechanism for rendering pages, such as a templating engine, XSLT, or something  of the sort.           !"#!"#$happstack-dlg-0.1Happstack.Server.Dialogs!Happstack.Server.Dialogs.Scaffold DialogManagerPageDlgperformshowPagemakeDialogManagercloseDialogManagerdialog Scaffoldedrenderparse escapeHtmlscaffoldsessionsopen DialogSessionclient lastToucheddialogsStepActionDone goodSessionwhileM uniqueKeycontainers-0.3.0.0Data.MapMapaddDialogSessiongetDialogSessionhappstack-server-0.5.0.2Happstack.Server.SimpleHTTP ServerPartT