How to flatten IO (IO ())?
问题 I'm just learning Haskell and monad transformers and I've found myself with an IO (IO ()) that I'd like to flatten into just IO (). I'm sure that I'm doing something wrong, but can't pinpoint exactly where I'm getting lost. Here is a simplified example of what I'm trying to do. This is a convoluted way of implementing echo , but it illustrates the problem. userInput :: Monad m => ReaderT (IO String) m (IO String) userInput = ask echo :: Monad m => ReaderT (IO String) m (IO ()) echo =