From d7e9e90017f1c9e6f515b6b5ab16d34966be070f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 7 Dec 2018 10:19:41 -0500 Subject: [PATCH] src/Misc.hs: fix monomorphism restriction warnings. --- src/Misc.hs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Misc.hs b/src/Misc.hs index c81d359..61c9d69 100644 --- a/src/Misc.hs +++ b/src/Misc.hs @@ -21,23 +21,23 @@ import Algebra.ToInteger ( C ) -- >>> partition 4 (-1) 1 -- [(-1.0,-0.5),(-0.5,0.0),(0.0,0.5),(0.5,1.0)] -- -partition :: (Algebra.Field.C a, Algebra.ToInteger.C b, Enum b) +partition :: forall a b. (Algebra.Field.C a, Algebra.ToInteger.C b, Enum b) => b -- ^ The number of subintervals to use, @n@ -> a -- ^ The \"left\" endpoint of the interval, @a@ -> a -- ^ The \"right\" endpoint of the interval, @b@ -> [(a,a)] -- Somebody asked for zero subintervals? Ok. partition 0 _ _ = [] -partition n a b +partition n x y | n < 0 = error "partition: asked for a negative number of subintervals" | otherwise = [ (xi, xj) | k <- [0..n-1], - let k' = fromIntegral k, - let xi = a + k'*h, - let xj = a + (k'+1)*h ] + let k' = fromIntegral k :: a, + let xi = x + k'*h, + let xj = x + (k'+1)*h ] where - coerced_n = fromIntegral $ toInteger n - h = (b-a)/coerced_n + coerced_n = fromIntegral $ toInteger n :: a + h = (y-x)/coerced_n -- | Compute the unit roundoff (machine epsilon) for this machine. We -- 2.43.2