From 2e9590ba9cc6b3605bcc1e30a74b2ae8aca56a44 Mon Sep 17 00:00:00 2001 From: Ross Paterson Date: Fri, 10 Nov 2006 14:11:20 +0000 Subject: [PATCH] move fix to Data.Function --- Control/Monad/Fix.hs | 6 +----- Data/Function.hs | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Control/Monad/Fix.hs b/Control/Monad/Fix.hs index e04a7f6..ea481d8 100644 --- a/Control/Monad/Fix.hs +++ b/Control/Monad/Fix.hs @@ -25,11 +25,7 @@ module Control.Monad.Fix ( import Prelude import System.IO import Control.Monad.Instances () - --- | @'fix' f@ is the least fixed point of the function @f@, --- i.e. the least defined @x@ such that @f x = x@. -fix :: (a -> a) -> a -fix f = let x = f x in x +import Data.Function (fix) -- | Monads having fixed points with a \'knot-tying\' semantics. -- Instances of 'MonadFix' should satisfy the following laws: diff --git a/Data/Function.hs b/Data/Function.hs index 1de5eac..bc851a0 100644 --- a/Data/Function.hs +++ b/Data/Function.hs @@ -14,6 +14,7 @@ module Data.Function ( -- * "Prelude" re-exports id, const, (.), flip, (\$) -- * Other combinators + , fix , on ) where @@ -21,6 +22,11 @@ import Prelude infixl 0 `on` +-- | @'fix' f@ is the least fixed point of the function @f@, +-- i.e. the least defined @x@ such that @f x = x@. +fix :: (a -> a) -> a +fix f = let x = f x in x + -- | @(*) \`on\` f = \\x y -> f x * f y@. -- -- Typical usage: @'Data.List.sortBy' ('compare' \`on\` 'fst')@. -- 1.9.1