Description of loop
from Control.Arrow
:
The loop operator expresses computations in which an output value is fed back as input, although the computation occurs only once. It underlies the rec value recursion construct in arrow notation.
Its source code, and its instantiation for (->)
:
class Arrow a => ArrowLoop a where
loop :: a (b,d) (c,d) -> a b c
instance ArrowLoop (->) where
loop f b = let (c,d) = f (b,d) in c
This immediately reminds me of fix
, the fixpoint combinator:
fix :: (a -> a) -> a
fix f = let x = f x in x
So my question is:
- Is it possible to implement that particular
loop
viafix
? - How are their functionalities different?
Kleisli IO
, isn'tmfix
enough? – Keto