如何理解/使用Haskell fix函数

如何理解/使用Haskell fix函数,haskell,fixpoint-combinators,Haskell,Fixpoint Combinators,我在xmonad包中看到以下代码: -- | Ignore SIGPIPE to avoid termination when a pipe is full, and SIGCHLD to -- avoid zombie processes, and clean up any extant zombie processes. installSignalHandlers :: MonadIO m => m () installSignalHandlers = io $ do inst

我在
xmonad
包中看到以下代码:

-- | Ignore SIGPIPE to avoid termination when a pipe is full, and SIGCHLD to
-- avoid zombie processes, and clean up any extant zombie processes.
installSignalHandlers :: MonadIO m => m ()
installSignalHandlers = io $ do
    installHandler openEndedPipe Ignore Nothing
    installHandler sigCHLD Ignore Nothing
    (try :: IO a -> IO (Either SomeException a))
      $ fix $ \more -> do
        x <- getAnyProcessStatus False False
        when (isJust x) more
    return ()
——|忽略SIGPPIPE以避免管道满时终止,SIGCHLD以
--避免僵尸进程,并清理任何现存的僵尸进程。
installSignalHandlers::MonadIO m=>m()
installSignalHandlers=io$do
installHandler OpenEndPipe不忽略任何内容
installHandler sigCHLD不忽略任何内容
(尝试::IO a->IO(某个异常a)
$fix$\more->do

x
fix
是用于实现递归的基本工具。它总是可以被递归的
let
替换,反之亦然,递归的
let
可以变成对
fix
的调用。在这个例子中

fix $ \more -> do
    x <- getAnyProcessStatus False False
    when (isJust x) more
fix$\more->do

x解释得很好。谢谢所以
more
这里有一个dumy变量,对吗?只在人们需要循环时使用?在这个用例中可以有循环计数器吗?@osager当然可以,计数器是可能的。
let more = do
        x <- getAnyProcessStatus False False
        when (isJust x) more
in more