Created
May 28, 2014 08:14
-
-
Save mwotton/ffa6dfb73fe3b0a8ef9b to your computer and use it in GitHub Desktop.
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
mvarEnumerator :: (MonadIO m, ToJSON a1) => (Async a, MVar a1) -> Step Builder m b -> Iteratee Builder m b | |
mvarEnumerator (task,mvar) step = case step of | |
Yield a b -> Iteratee . return . Yield a $ b | |
Continue s -> do | |
r' <- liftIO $ race (wait task) (takeMVar mvar) | |
s $ case r' of | |
Left _ -> EOF | |
Right r -> Chunks [fromLazyByteString $ encode r] | |
Error s -> error (show s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment