4
如何從haskell中獲得前一個操作的輸出並使用>>=
進行打印?使用>> =在haskell中重定向上次操作的stdout
殼,很是喜歡,
echo "hello world" | { read test; echo test=$test; }
在Haskell,我期待這樣的事情,
putStrLn "hello world" >>= {x <- getArgs; print x}
getArgs標準輸入必須從putStrLn的stdout其輸入。
編輯#1, Alexey & aochagavia,感謝您的意見。這工作。
x :: IO String
x = return "hello world"
main = do
x >>= print
您的代碼不能編譯。檢查'return'的類型簽名:'return :: Monad m => a - > m a'。也許你可以看看http://learnyouahaskell.com/input-and-output – aochagavia
刪除'return' ...但仍然錯誤,我正在調試它 –
你可以去http://chat.stackoverflow.com/rooms/83002/haskell-room在聊天中討論它 – aochagavia