2006-08-24 [長年日記]

[Haskell] NewCGIを使ってCGIを書く

{-# OPTIONS_GHC -fallow-overlapping-instances #-}

import Network.NewCGI

main :: IO ()
main = runCGI (handleErrors cgiMain)

cgiMain :: CGI CGIResult
cgiMain = do setHeader "Content-Type" "text/plain; charset=us-ascii"
             output "Hello, world!"

ちなみに、NewCGIには以下のパッチを当てないとビルドできません。

diff -ur cgi-2006.8.5.orig/Network/NewCGI.hs cgi-2006.8.5/Network/NewCGI.hs
--- cgi-2006.8.5.orig/Network/NewCGI.hs	2006-08-05 12:55:00.000000000 -0400
+++ cgi-2006.8.5/Network/NewCGI.hs	2006-08-17 02:48:48.000000000 -0400
@@ -1,3 +1,4 @@
+{-# OPTIONS_GHC -fallow-overlapping-instances #-}
 -----------------------------------------------------------------------------
 -- |
 -- Module      :  Network.NewCGI
[]