Commits

Luke Plant committed bfa6d52

Made more use of 'View' type alias

Comments (0)

Files changed (2)

src/Blog/Views.hs

 import Data.ByteString.Lazy.Char8 (ByteString)
 import qualified Data.ByteString.Lazy.Char8 as BS
 import Web.Utils
+import Web.Framework (View)
 import Text.XHtml
 
 mainIndexPage = body << h1 << "Hello, from Luke's web framework"
 
-mainIndex :: Request -> IO (Maybe Response)
+mainIndex :: View
 mainIndex req = let resp = buildResponse utf8HtmlResponse [
                             addContent $ BS.pack $ renderHtml mainIndexPage
                            ]

src/Web/Framework.hs

                      , default404
                      , DispatchOptions(..)
                      , defaultDispatchOptions
+                     , View
                      )
 
 where
 -- | Handle a CGI request using a list of possible views
 -- If a view returns 'Nothing' the next will be tried,
 -- and a 404 issued if all return nothing
-dispatchCGI :: [Request -> IO (Maybe Response)] -- list of views that will be tried in order
+dispatchCGI :: [View] -- list of views functions that will be tried in order
             -> DispatchOptions                  -- options to use in dispatching
             -> IO ()
 dispatchCGI views opts = do