How to use bind with nested monads?
问题 I have two functions, one that tries to get a token from a webservice and may fail, and one that tries to use this token to get the username and may fail. getToken :: IO (Maybe Token) getUsername :: Token -> IO (Maybe String) I would like to take the result of getToken and feed it to getUsername . If there was only IO or Maybe , I could simply use bind, but since there are down nested monads, I can't. How can I write something equivalent to getToken >>= getUsername :: IO (Maybe String) ? More