FW: MonadFix

Levent Erkok erkok@cse.ogi.edu
Fri, 1 Feb 2002 09:32:04 +0000


On Friday 01 February 2002 10:41 am, Simon Marlow wrote:
> I'm agnostic on the naming issue.  Point 2: I don't think we should
> remove the export of 'fix', as we're generally moving in the direction
> of encouraging the use of qualified names.  Points 3 & 4: sure.

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..

-Levent.