buster 0.99.6 → 0.99.7
raw patch · 3 files changed
+11/−13 lines, 3 files
Files
- App/Behaviours/FileOps.hs +8/−8
- App/Behaviours/HTTP.hs +2/−4
- buster.cabal +1/−1
App/Behaviours/FileOps.hs view
@@ -33,7 +33,7 @@ readFileBehaviour n d b = consumeNamedEventsWith b n readFileCatch where readFileCatch e = Ex.catch (readFile0 e) (emitException e) readFile0 e = (rFile0 d . eventdata $ e) >>= produce n "ReadSource" (filename e) Persistent >>= return . (:[])- emitException e (ex :: Ex.SomeException) = produce "Exception" "readFileBehaviour" n once (EString (show ex):eventdata e) >>= return . (:[])+ emitException e ex = produce "Exception" "readFileBehaviour" n once (EString (show ex):eventdata e) >>= return . (:[]) filename = (\(EString x) -> x) . head . eventdata -- | @readFileBehaviourNR name datatype@ looks for any event with the name /name/ and reads the file@@ -57,7 +57,7 @@ readFileBehaviourNR n d b = consumeNamedEventsWith b n readFileCatch where readFileCatch e = Ex.catch (readFile0 e) (emitException e) readFile0 e = (rFile d . eventdata $ e) >>= produce n "ReadSource" (filename e) Persistent >>= return . (:[])- emitException e (ex :: Ex.SomeException) = produce "Exception" "readFileBehaviour" n once (EString (show ex):eventdata e) >>= return . (:[])+ emitException e ex = produce "Exception" "readFileBehaviour" n once (EString (show ex):eventdata e) >>= return . (:[]) filename = (\(EString x) -> x) . head . eventdata -- | @decodeFileBehaviour name datatype@ looks for any event with the name /name/ and reads the file@@ -81,7 +81,7 @@ decodeFileBehaviour n d b = consumeNamedEventsWith b n decodeFileCatch where decodeFileCatch e = Ex.catch (decodeFile0 e) (emitException e) decodeFile0 e = (dFile0 d . eventdata $ e) >>= produce n "ReadSource" (filename e) Persistent >>= return . (:[])- emitException e (ex :: Ex.SomeException) = produce "Exception" "decodeFileBehaviour" n once (EString (show ex):eventdata e) >>= return . (:[])+ emitException e ex = produce "Exception" "decodeFileBehaviour" n once (EString (show ex):eventdata e) >>= return . (:[]) filename = (\(EString x) -> x) . head . eventdata -- | @readFileBehaviour name datatype@ looks for any event with the name /name/ and reads the file@@ -104,7 +104,7 @@ decodeFileBehaviourNB n d b = consumeNamedEventsWith b n decodeFileCatch where decodeFileCatch e = Ex.catch (decodeFile0 e) (emitException e) decodeFile0 e = (dFile d . eventdata $ e) >>= (produce n "ReadSource" (filename e) Persistent) >>= return . (:[])- emitException e (ex :: Ex.SomeException) = produce "Exception" "decodeFileBehaviourNB" n once (EString (show ex):eventdata e) >>= return . (:[])+ emitException e ex = produce "Exception" "decodeFileBehaviourNB" n once (EString (show ex):eventdata e) >>= return . (:[]) filename = (\(EString x) -> x) . head . eventdata -- | @writeFileBehaviour@ looks for \"WriteFile\" named events with event data corresponding to@@ -114,7 +114,7 @@ writeFileBehaviourNS :: Behaviour [EData a] writeFileBehaviourNS b = consumeNamedEventsWith b "WriteFile" $ \e -> Ex.catch (wFile . eventdata $ e)- (\(ex :: Ex.SomeException) -> produce "Exception" "writeFileBehaviourNS" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[]))+ (\ex -> produce "Exception" "writeFileBehaviourNS" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[])) -- | @writeFileBehaviour@ looks for \"WriteFile\" named events with event data corresponding to -- @[EString filepath,@ /data constructor/ @contents]@ and removes them from the bus, writing@@ -125,7 +125,7 @@ writeFileBehaviour :: Show a => Behaviour [EData a] writeFileBehaviour b = consumeNamedEventsWith b "WriteFile" $ \e -> Ex.catch (wFile0 . eventdata $ e)- (\(ex :: Ex.SomeException) -> produce "Exception" "writeFileBehaviour" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[]))+ (\ex -> produce "Exception" "writeFileBehaviour" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[])) -- | @writeFileBehaviour@ looks for \"WriteFile\" named events with event data corresponding to -- @[EString filepath,@ /data constructor/ @contents]@ and removes them from the bus, writing@@ -136,7 +136,7 @@ encodeFileBehaviourNB :: Behaviour [EData a] encodeFileBehaviourNB b = consumeNamedEventsWith b "WriteBinary" $ \e -> Ex.catch (wBinary . eventdata $ e)- (\(ex :: Ex.SomeException) -> produce "Exception" "encodeFileBehaviourNB" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[]))+ (\ex -> produce "Exception" "encodeFileBehaviourNB" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[])) -- | @writeFileBehaviour@ looks for \"WriteFile\" named events with event data corresponding to -- @[EString filepath,@ /data constructor/ @contents]@ and removes them from the bus, writing@@ -147,7 +147,7 @@ encodeFileBehaviour :: Binary a => Behaviour [EData a] encodeFileBehaviour b = consumeNamedEventsWith b "WriteBinary" $ \e -> Ex.catch (wBinary0 . eventdata $ e)- (\(ex :: Ex.SomeException) -> produce "Exception" "encodeFileBehaviour" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[]))+ (\ex -> produce "Exception" "encodeFileBehaviour" "WriteFile" once (EString (show ex):eventdata e) >>= return . (:[])) wFile [EString filepath, EString contents] = [] <$ writeFile filepath contents wFile [EString filepath, EStringL contents] = [] <$ (writeFile filepath . unlines $ contents)
App/Behaviours/HTTP.hs view
@@ -9,7 +9,7 @@ -- Stability : Experimental -- Portability : ----- | Behaviours for HTTP GET and POST requests. Looks for Events named+-- | Behaviours for HTTP requests. Looks for Events named -- HTTP\//MethodName/ with event data of [EString uri, EByteString senddata, EStringL headers] and consumes them. Produces -- Events named HTTPResponse with source httpBehaviour\//MethodName/ and the contents of the response as the event data in a ByteString. -- They also produce Exceptions with the same source and name ConnectionError if there is no network connection or HTTP Service@@ -42,15 +42,13 @@ headers (EString nm:EString val:hs) = Header (HdrCustom nm) val : headers hs headers [] = [] - httpGet uri = (simpleHTTP $ Request uri method postheaders postdata) >>=+ httpGet uri = (Network.HTTP.HandleStream.simpleHTTP $ Request uri method postheaders postdata) >>= either (\_ -> produce "Exception" ("httpBehaviour" ++ show method) "ConnectionError" once []) (\(Response code reason rspheaders contents) -> case code of (1,_,_) -> produce "HTTPResponse" ("httpBehaviour/" ++ show method) (show uri) Persistent [EByteString contents] (2,_,_) -> produce "HTTPResponse" ("httpBehaviour/" ++ show method) (show uri) Persistent [EByteString contents] _ -> produce "Exception" ("httpBehaviour/" ++ show method) "HTTPErrorResponseCode" once [EString (show code), EStringL . map show $ rspheaders, EByteString contents])-- in case parseURI uriS of Just uri -> listM $ httpGet uri Nothing -> listM $ produce "Exception" ("httpBehaviour" ++ show method) "ParseFailure" once [EString uriS]
buster.cabal view
@@ -1,5 +1,5 @@ name: buster-version: 0.99.6+version: 0.99.7 cabal-version: -any build-type: Simple license: BSD3