[Haskell-cafe] network.cgi - incomplete translation of code to javascript

Andrew U. Frank frank22 at geoinfo.tuwien.ac.at
Thu Aug 5 18:23:43 EDT 2010

i try to use the Network.CGI package from darcs. my testing uses the
        example code from the webpage 'practical web programming in
        specifically the example with code:
        import Network.CGI
        import Text.XHtml
        inputForm = form << [paragraph << ("My name is " +++ textfield
                             submit "" "Submit"]
        greet n = paragraph << ("Hello " ++ n ++ "!")
        page t b = header << thetitle << t +++ body << b
        cgiMain = do mn <- getInput "name"
                     let x = maybe inputForm greet mn
                     output $ renderHtml $ page "Input example" x
        main = runCGI $ handleErrors cgiMain
        -- Get the value of an input variable, for example from a form. 
        -- If the variable has multiple values, the first one is
        -- getInput :: String -> CGI (Maybe String)
        this runs (runghc) and produces the output:
        <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        <html xmlns="http://www.w3.org/1999/xhtml"
            >Input example</title
              >My name is <input type="text" name="name" id="name"
              ><input type="submit" value="Submit"
        which is clearly not producing the second part of the code,
        namely output a greeting.
        the same happens with the next example, using cookies, where
        from two options for pattern matching only the first is include
        in the javascript.
        i assume that i do something wrong - but what?
        any help is appreciated!

More information about the Haskell-Cafe mailing list