0

Looking at this ZeroMQ HelloWorldClient.hs code snippet:

forM_ [1..10] $ \i -> do
    liftIO . putStrLn $ "Sending Hello " ++ show i ++ "…"
    send requester [] "Hello"
    _ <- receive requester
    liftIO . putStrLn $ "Received World " ++ show i

Is there any reason why _ <- receive requester wouldn't be written as receive requester?

Also, in general, is there any reason to use _ <- f (where f : Monad m => m a) instead of f?

4

1 回答 1

8

That's a common way to silence warnings about throwing away a value, when you've got something of type m a where a is not (). Another common way to do this is with void.

于 2016-05-13T01:25:20.297 回答