Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
simonpj
committed
Apr 19, 2011
1 parent
3214a30
commit bde76b2
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{-# LANGUAGE Arrows, FunctionalDependencies, FlexibleContexts, | ||
MultiParamTypeClasses, RecordWildCards #-} | ||
|
||
module T5045 where | ||
|
||
import Control.Arrow | ||
|
||
class (Control.Arrow.Arrow a') => ArrowAddReader r a a' | a -> a' where | ||
elimReader :: a e b -> a' (e, r) b | ||
|
||
newtype ByteString = FakeByteString String | ||
|
||
pathInfo :: Monad m => m String | ||
pathInfo = undefined | ||
|
||
requestMethod :: Monad m => m String | ||
requestMethod = undefined | ||
|
||
getInputsFPS :: Monad m => m [(String, ByteString)] | ||
getInputsFPS = undefined | ||
|
||
class HTTPRequest r s | r -> s where | ||
httpGetPath :: r -> String | ||
httpSetPath :: r -> String -> r | ||
httpGetMethod :: r -> String | ||
httpGetInputs :: r -> [(String, s)] | ||
|
||
data CGIDispatch = CGIDispatch { | ||
dispatchPath :: String, | ||
dispatchMethod :: String, | ||
dispatchInputs :: [(String, ByteString)] } | ||
|
||
instance HTTPRequest CGIDispatch ByteString where | ||
httpGetPath = dispatchPath | ||
httpSetPath r s = r { dispatchPath = s } | ||
httpGetMethod = dispatchMethod | ||
httpGetInputs = dispatchInputs | ||
|
||
runDispatch :: (Arrow a, ArrowAddReader CGIDispatch a a', Monad m) => a b c -> m (a' b c) | ||
runDispatch a = do | ||
dispatchPath <- pathInfo | ||
dispatchMethod <- requestMethod | ||
dispatchInputs <- getInputsFPS | ||
return $ proc b -> (| elimReader (a -< b) |) CGIDispatch { .. } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
:l T5045.hs | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters