X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=Data%2FFunction.hs;h=64ebfd09aa9bfb403f178c80abcd5cb758926b23;hb=HEAD;hp=1de5eac4692d639f5c91d431dc7786fbf18a5857;hpb=f47563670afa988019462f1dfcce87d10b4c5221;p=ghc-base.git diff --git a/Data/Function.hs b/Data/Function.hs index 1de5eac..64ebfd0 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')@. @@ -74,4 +80,4 @@ infixl 0 `on` -- flip on (g . f) on :: (b -> b -> c) -> (a -> b) -> a -> a -> c -(*) `on` f = \x y -> f x * f y +(.*.) `on` f = \x y -> f x .*. f y