GHC会默认对以下函数进行尾调用优化吗?唯一奇怪的是它递归地定义了一个 IO 操作,但我不明白为什么这不能成为 TCO。
import Control.Concurrent.MVar
consume :: MVar a -> [a] -> IO ()
consume _ [] = return ()
consume store (x:xs) = do putMVar store x
consume store xs
GHC会默认对以下函数进行尾调用优化吗?唯一奇怪的是它递归地定义了一个 IO 操作,但我不明白为什么这不能成为 TCO。
import Control.Concurrent.MVar
consume :: MVar a -> [a] -> IO ()
consume _ [] = return ()
consume store (x:xs) = do putMVar store x
consume store xs