essence-of-live-coding-warp 0.2.1 → 0.2.2
raw patch · 3 files changed
+18/−15 lines, 3 filesdep ~essence-of-live-codingPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: essence-of-live-coding
API changes (from Hackage documentation)
- LiveCoding.Warp: runWarpC :: Port -> Cell IO (a, Request) (b, Response) -> Cell (HandlingStateT IO) a b
+ LiveCoding.Warp: runWarpC :: Port -> Cell IO (a, Request) (b, Response) -> Cell (HandlingStateT IO) a (Maybe b)
Files
- CHANGELOG.md +4/−0
- essence-of-live-coding-warp.cabal +4/−4
- src/LiveCoding/Warp.hs +10/−11
CHANGELOG.md view
@@ -1,5 +1,9 @@ # Revision history for essence-of-live-coding-warp +## 0.2.2++* Made backend nonblocking+ ## 0.2.1 * Simple single-threaded version
essence-of-live-coding-warp.cabal view
@@ -1,5 +1,5 @@ name: essence-of-live-coding-warp-version: 0.2.1+version: 0.2.2 synopsis: General purpose live coding framework description: essence-of-live-coding is a general purpose and type safe live coding framework.@@ -33,7 +33,7 @@ source-repository this type: git location: git@github.com:turion/essence-of-live-coding.git- tag: v0.2.1+ tag: v0.2.2 library exposed-modules:@@ -44,7 +44,7 @@ , http-types >= 0.12.3 , wai >= 3.2.2.1 , warp >= 3.3.13- , essence-of-live-coding >= 0.2.1+ , essence-of-live-coding >= 0.2.2 hs-source-dirs: src default-language: Haskell2010 default-extensions: StrictData@@ -56,6 +56,6 @@ build-depends: base >= 4.11 && < 5 , http-client >= 0.7.1- , essence-of-live-coding >= 0.2.1+ , essence-of-live-coding >= 0.2.2 , essence-of-live-coding-warp default-language: Haskell2010
src/LiveCoding/Warp.hs view
@@ -46,28 +46,27 @@ {- | Run a 'Cell' as a WARP application. 1. Starts a WARP application on the given port in a background thread-2. Block until the next request arrives+2. Waits until the next request arrives, outputting 'Nothing' in the meantime 3. Supplies the cell with the input and the current request 4. Serve the response and return the output--Keep in mind that the resulting cell is blocking.-For a non-blocking cell, use 'LiveCoding.NonBlocking'. -} runWarpC :: Port -> Cell IO (a, Request) (b, Response)- -> Cell (HandlingStateT IO) a b+ -> Cell (HandlingStateT IO) a (Maybe b) runWarpC port cell = proc a -> do WaiHandle { .. } <- handling $ waiHandle port -< ()- request <- arrM $ liftIO . takeMVar -< requestVar- (b, response) <- liftCell cell -< (a, request)- arrM $ liftIO . uncurry putMVar -< (responseVar, response)- returnA -< b-+ requestMaybe <- arrM $ liftIO . tryTakeMVar -< requestVar+ case requestMaybe of+ Just request -> do+ (b, response) <- liftCell cell -< (a, request)+ arrM $ liftIO . uncurry putMVar -< (responseVar, response)+ returnA -< Just b+ Nothing -> returnA -< Nothing runWarpC_ :: Port -> Cell IO Request Response -> Cell (HandlingStateT IO) () ()-runWarpC_ port cell = runWarpC port $ arr snd >>> cell >>> arr ((), )+runWarpC_ port cell = runWarpC port (arr snd >>> cell >>> arr ((), )) >>> arr (const ())