
Why don't we put "fix" into another library, and let MonadRec Arrow, etc. import it? Fixed-point operators show up quite often to deserve a library of their own: If all I care about is "fix", I shouldn't be forced to "import MonadRec". This new library can include various flavors of fix:
fix :: (a -> a) -> a -- usual fixed-points fix f = let a = f a in a
nthApprox :: Integer -> (a -> a) -> a -- approximations to fix nthApprox n f = (iterate f undefined) !! n
trace :: ((a, u) -> (b, u)) -> (a, b) -- traces trace f a = let (b, u) in f (a, u) in b
pFix :: ((a, u) -> u) -> (a -> u) -- parameterized fix pFix f a = let (a, u) = f u in u
Then MonadRec, Arrow, or whoever just needs fixed-point operators can import it from there..
This sounds fine to me. It should probably go in Control.Fix. Levent: would you like to suggest a full contents for this library? Cheers, Simon

On Monday 25 February 2002 10:42 am, Simon Marlow wrote:
This sounds fine to me. It should probably go in Control.Fix. Levent: would you like to suggest a full contents for this library?
Sorry for the late reply. Modulo names, I think the attached library should do it. -Levent.

On Sun, Mar 03, 2002 at 11:38:44PM +0000, Levent Erkok wrote:
On Monday 25 February 2002 10:42 am, Simon Marlow wrote:
This sounds fine to me. It should probably go in Control.Fix. Levent: would you like to suggest a full contents for this library?
Sorry for the late reply. Modulo names, I think the attached library should do it.
I'd suggest that traceFix be renamed trace; it will be used by Control.Arrow. But is anyone ever going to use nthFix or paramFix? The former is only useful in proofs, while the latter is easily available as paramFix :: ((a, u) -> u) -> a -> u paramFix f a = fix (curry f a) How about a Control.Function module, with fix, trace and compose :: [a -> a] -> a -> a compose = foldr (.) id times :: Integral n => n -> (a -> a) -> a -> a times n f = compose (genericReplicate n f) so then nthFix n f = times n f undefined. Maybe some of the prelude functions would belong in there too.

I agree that nthFix is mainly useful in proofs. Similarly for paramFix. But if we are having a separate library for "fix"-like functions, I don't see any harm in putting them there as well. The general idea of Control.Function looks good too. I used the name "traceFix" to avoid clash with the "trace" debugging primitive. It sounds too much like a debugging function in any case. -Levent. On Monday 04 March 2002 11:34 am, Ross Paterson wrote:
On Sun, Mar 03, 2002 at 11:38:44PM +0000, Levent Erkok wrote:
On Monday 25 February 2002 10:42 am, Simon Marlow wrote:
This sounds fine to me. It should probably go in Control.Fix. Levent: would you like to suggest a full contents for this library?
Sorry for the late reply. Modulo names, I think the attached library should do it.
I'd suggest that traceFix be renamed trace; it will be used by Control.Arrow. But is anyone ever going to use nthFix or paramFix? The former is only useful in proofs, while the latter is easily available as
paramFix :: ((a, u) -> u) -> a -> u paramFix f a = fix (curry f a)
How about a Control.Function module, with fix, trace and
compose :: [a -> a] -> a -> a compose = foldr (.) id
times :: Integral n => n -> (a -> a) -> a -> a times n f = compose (genericReplicate n f)
so then nthFix n f = times n f undefined. Maybe some of the prelude functions would belong in there too.

On Mon, Mar 04, 2002 at 09:40:48AM +0000, Levent Erkok wrote:
I agree that nthFix is mainly useful in proofs. Similarly for paramFix. But if we are having a separate library for "fix"-like functions, I don't see any harm in putting them there as well.
I was thinking that if there's only one really useful function (fix) it hardly warrants a whole module.
I used the name "traceFix" to avoid clash with the "trace" debugging primitive. It sounds too much like a debugging function in any case.
Ah, but we have modules for namespace control. On the other hand, this function is probably of no use to any module other than Arrow (so might as well be there).
participants (3)
-
Levent Erkok
-
Ross Paterson
-
Simon Marlow