From d2222aa1c04ba9c0eb80a03149abdf7d86eca032 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 7 Dec 2018 10:33:43 -0500 Subject: [PATCH] src/Roots/Fast.hs: fix monomorphism restriction warnings. --- src/Roots/Fast.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Roots/Fast.hs b/src/Roots/Fast.hs index e5321c9..a879950 100644 --- a/src/Roots/Fast.hs +++ b/src/Roots/Fast.hs @@ -1,4 +1,5 @@ {-# LANGUAGE RebindableSyntax #-} +{-# LANGUAGE ScopedTypeVariables #-} -- | The Roots.Fast module contains faster implementations of the -- 'Roots.Simple' algorithms. Generally, we will pass precomputed @@ -148,7 +149,7 @@ fixed_point_iterations = -- -- We also return the number of iterations required. -- -fixed_point_with_iterations :: (Normed a, +fixed_point_with_iterations :: forall a b. (Normed a, Additive.C a, RealField.C b, Algebraic.C b) @@ -165,12 +166,13 @@ fixed_point_with_iterations f epsilon x0 = abs_diff v w = norm (v - w) -- The nth entry in this list is the absolute value of x_{n} - - -- x_{n+1}. - differences = zipWith abs_diff xn xn_plus_one + -- x_{n+1}. They're of type "b" because we're going to compare + -- them against epsilon. + differences = zipWith abs_diff xn xn_plus_one :: [b] -- This produces the list [(n, xn)] so that we can determine -- the number of iterations required. - numbered_xn = zip [0..] xn + numbered_xn = zip [0..] xn :: [(Int,a)] -- A list of pairs, (xn, |x_{n} - x_{n+1}|). pairs = zip numbered_xn differences -- 2.44.2