Fixed point combinator for mutually recursive functions?

后端 未结 3 1552
眼角桃花
眼角桃花 2021-01-02 01:38

Is there a fixed point combinator for creating tuples of mutually recursive functions? I.e. I\'m looking for something like the Y-Combinator but which takes multiple \"recu

3条回答
  •  粉色の甜心
    2021-01-02 02:08

    I'm not entirely sure about this one. I'm still trying to find a formal proof of it. But it seems to me you don't need one. In Haskell, if you have something like:

    fix :: (a -> a) -> a
    fix f = let x = f x in x

    main = let { x = ... y ...; y = ... x ... } in x

    you can rewrite main to

    main = fst $ fix $ \(x, y) -> (... y ..., ... x ...)

    But like I said, I'm not 100% sure about this one.

提交回复
热议问题