{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.HTTP.Types (status200)
import Network.Wai.Handler.Warp (run)
application _ = return $
responseLBS status200 [("Content-Type", "text/plain")] "Hello World"
main = run 3000 application{-# LANGUAGE OverloadedStrings #-}
import Network.Wai
import Network.Wai.Handler.Warp (run)
import Network.Wai.Middleware.Gzip (gzip, def)
import Network.HTTP.Types (status200)
application _ = return $
responseLBS status200 [("Content-Type", "text/plain")] "Hello World"
main = run 3000 $ gzip def application

app req = return $ case pathInfo req of ["yay"] -> yay -- url-bestandteile ohne query-string x -> index x -- evtl. 404yay = ResponseBuilder status200 ...index x = ResponseBuilder status200 ...
...server { listen 80; server_name www.myserver.com; location / { proxy_pass http://127.0.0.1:3000; } }...
/ HomeR METHOD
/route RouteR METHOD METHOD
/route/#routeVar RouteVarR METHOD
/route/*routeVars RouteVarsR METHOD
/static StaticR Static getStatic/route RouteR METHOD ...
-- wird zu
methodRoute :: Handler Html-- route
/route RouteR GET
-- handler
getRoute :: Handler -> Html-- route
/route RouteR POST
-- handler
postRoute :: Handler -> Text-- route
/route RouteR
-- handler
handleRoute :: Handler -> Html-- route/route/#URLType RouteR METHOD-- PathPiece methodsinstance PathPiece URLType wheretoPathPiece (URLType t) = toPathPiece tfromPathPiece p = dot <- fromPathPiece preturn $ URLType tfromPathPiece _ = Nothing -- nicht immer erforderlich, evtl. 404?
instance PathPiece Bool wheretoPathPiece b = toPathPiece (if b then 1 else 0 :: Int)fromPathPiece p = dox <- fromPathPiece pcase x :: Int of0 -> return False1 -> return True_ -> Nothing
-- route/route/*URLType RouteR METHOD-- PathMultiPiece methodsinstance PathMultiPiece URLType wheretoPathMultiPiece (URLType t1 t2) = [toPathPiece t1, toPathPiece t2]fromPathMultiPiece [p1,p2] = dot1 <- fromPathPiece p1t2 <- fromPathPiece p2return $ URLType t1 t2fromPathMultiPiece _ = Nothing -- evtl. 404?
data Natural = Natural Integer deriving (Eq, Show, Read)
data Binary = Binary String deriving (Eq, Show, Read)toBinary :: Natural -> Binary
toBinary n = Binary $ getBinary $ fromNatural n where
getBinary i = showIntAtBase 2 intToDigit i ""
fromBinary :: Binary -> String
fromBinary (Binary b) = btoNatural :: Binary -> Natural
toNatural b = Natural $ bin2dec $ fromBinary b where
bin2dec = foldr (\c s -> s * 2 + c) 0 . reverse . map c2i where
c2i '0' = 0
c2i '1' = 1
c2i _ = error "no binary"
fromNatural :: Natural -> Integer
fromNatural (Natural n) = n