Created
December 11, 2020 23:11
-
-
Save exarkun/e1b0c67e409c3223206d60256fe31b5e 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
yieldFirst :: MVar o -> MVar o -> ConduitT () o IO () | |
yieldFirst left right = do | |
repeatMC $ winner left right >>= return . unwrap | |
return () | |
where | |
winner :: MVar o -> MVar o -> IO (Either o o) | |
winner left right = race (takeMVar left) (takeMVar right) | |
unwrap :: Either o o -> o | |
unwrap (Left o) = o | |
unwrap (Right o) = o |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment