Skip to content

Instantly share code, notes, and snippets.

@spion
Last active September 18, 2015 16:17
Show Gist options
  • Save spion/33a03695b970721f3425 to your computer and use it in GitHub Desktop.
Save spion/33a03695b970721f3425 to your computer and use it in GitHub Desktop.
getDataAsync :: String -> IO (IO ByteString)
getDataAsync url = do
m <- newEmptyMVar
_ <- forkIO $ HTTP.simpleHttp url >>= putMVar m
return $ readMVar m
-- More generally:
async :: IO a -> IO (IO a)
async action = do
m <- newEmptyMVar
_ <- forkIO $ action >>= putMVar m
return $ readMVar m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment