From 2954c33576b4119927ba4744930439e9636257df Mon Sep 17 00:00:00 2001 From: Brent Yorgey Date: Mon, 12 Feb 2024 17:14:37 -0600 Subject: [PATCH] fix a few GHC 9.8 warnings --- src/Diagrams/CubicSpline/Internal.hs | 8 +++++--- src/Diagrams/TwoD/Points.hs | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Diagrams/CubicSpline/Internal.hs b/src/Diagrams/CubicSpline/Internal.hs index 1087d4e5..d3ec54b5 100644 --- a/src/Diagrams/CubicSpline/Internal.hs +++ b/src/Diagrams/CubicSpline/Internal.hs @@ -50,12 +50,14 @@ solveCubicSplineDerivativesClosed xs = solveCyclicTriDiagonal as bs as ds 1 1 solveCubicSplineCoefficients :: Fractional a => Bool -> [a] -> [[a]] solveCubicSplineCoefficients closed xs = [ [x,d,3*(x1-x)-2*d-d1,2*(x-x1)+d+d1] - | (x,x1,d,d1) <- zip4 xs' (tail xs') ds' (tail ds') + | (x,x1,d,d1) <- zip4 xs' (drop 1 xs') ds' (drop 1 ds') ] where ds | closed = solveCubicSplineDerivativesClosed xs | otherwise = solveCubicSplineDerivatives xs - close as | closed = as ++ [head as] - | otherwise = as + close [] = [] + close as@(a:_) + | closed = as ++ [a] + | otherwise = as xs' = close xs ds' = close ds diff --git a/src/Diagrams/TwoD/Points.hs b/src/Diagrams/TwoD/Points.hs index 6394a76e..65e13f3f 100644 --- a/src/Diagrams/TwoD/Points.hs +++ b/src/Diagrams/TwoD/Points.hs @@ -24,16 +24,16 @@ import Linear.Affine -- | Find the convex hull of a list of points using Andrew's monotone chain -- algorithm O(n log n). --- +-- -- Returns clockwise list of points starting from the left-most point. convexHull2D :: OrderedField n => [P2 n] -> [P2 n] -convexHull2D ps = init upper ++ reverse (tail lower) +convexHull2D ps = init upper ++ reverse (drop 1 lower) where (upper, lower) = sortedConvexHull (sort ps) --- | Find the convex hull of a set of points already sorted in the x direction. --- The first list of the tuple is the upper hull going clockwise from --- left-most to right-most point. The second is the lower hull from +-- | Find the convex hull of a set of points already sorted in the x direction. +-- The first list of the tuple is the upper hull going clockwise from +-- left-most to right-most point. The second is the lower hull from -- right-most to left-most in the anti-clockwise direction. sortedConvexHull :: OrderedField n => [P2 n] -> ([P2 n], [P2 n]) sortedConvexHull ps = (chain True ps, chain False ps)