Naïve optimization by stepping until the error falls below a threshold
The guys at #haskell pointed me to until. This makes it satisfactory to me.

f :: Num a =&gt; a -&gt; a
f x = abs(42-x)^2

improve :: Fractional b =&gt; (b -&gt; c) -&gt; (b, a) -&gt; (b, c)
improve f (x, _) = (newX, f newX) where newX = x+0.1

optimize:: (Ord a, Fractional b) =&gt; (b -&gt; a) -&gt; a -&gt; b -&gt; (b, a)
optimize f goal x = until isDone (improve f) (0, f x)
    where isDone (_, err) = err &lt; goal

main :: IO ()
main = print $ optimize f 0.5 0


http://ideone.com/ZlC7x8