From 38b68b8c9b83fc7bc9c6a2c9535a50a904d20b08 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 7 Dec 2018 10:47:20 -0500 Subject: [PATCH] src/Integration/Trapezoid.hs: fix monomorphism restriction warning. --- src/Integration/Trapezoid.hs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Integration/Trapezoid.hs b/src/Integration/Trapezoid.hs index df4da78..807bbc5 100644 --- a/src/Integration/Trapezoid.hs +++ b/src/Integration/Trapezoid.hs @@ -1,4 +1,5 @@ {-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE RebindableSyntax #-} module Integration.Trapezoid ( @@ -36,15 +37,15 @@ import qualified Algebra.ToRational as ToRational ( C ) -- >>> trapezoid_1 f (-1) 1 -- 2.0 -- -trapezoid_1 :: (Field.C a, ToRational.C a, Field.C b) +trapezoid_1 :: forall a b. (Field.C a, ToRational.C a, Field.C b) => (a -> b) -- ^ The function @f@ -> a -- ^ The \"left\" endpoint, @a@ -> a -- ^ The \"right\" endpoint, @b@ -> b -trapezoid_1 f a b = - (((f a) + (f b)) / 2) * coerced_interval_length +trapezoid_1 f x y = + (((f x) + (f y)) / 2) * coerced_interval_length where - coerced_interval_length = fromRational' $ toRational (b - a) + coerced_interval_length = fromRational' $ toRational (y - x) :: b -- | Use the composite trapezoid rule to numerically integrate @f@ -- over @n@ subintervals of [@a@, @b@]. -- 2.43.2