Skip to content

Commit

Permalink
Criterion.Analysis: Fix -Wx-partial warning
Browse files Browse the repository at this point in the history
This was uncovered by GHC 9.8, where -Wx-partial is included in -Wall.
  • Loading branch information
RyanGlScott committed Aug 8, 2023
1 parent 8d97e04 commit e1ae3f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Criterion/Analysis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import Criterion.Measurement (secs, threshold)
import Criterion.Monad (Criterion, getGen)
import Criterion.Types
import Data.Int (Int64)
import Data.List.NonEmpty (NonEmpty(..))
import Data.Maybe (fromJust)
import Prelude ()
import Prelude.Compat
Expand All @@ -52,6 +53,7 @@ import Statistics.Sample.KernelDensity (kde)
import Statistics.Types (Sample)
import System.Random.MWC (GenIO)
import qualified Data.List as List
import qualified Data.List.NonEmpty as NE
import qualified Data.Map as Map
import qualified Data.Vector as V
import qualified Data.Vector.Generic as G
Expand Down Expand Up @@ -207,9 +209,9 @@ regress gen predNames respName meas = do
, regRSquare = r2
}

singleton :: [a] -> Bool
singleton [_] = True
singleton _ = False
singleton :: NonEmpty a -> Bool
singleton (_ :| []) = True
singleton _ = False

-- | Given a list of accessor names (see 'measureKeys'), return either
-- a mapping from accessor name to function or an error message if
Expand All @@ -233,8 +235,8 @@ validateAccessors predNames respName = do
when (null predNames) $
Left "no predictors specified"
let names = respName:predNames
dups = map head . filter (not . singleton) .
List.group . List.sort $ names
dups = map NE.head . List.filter (not . singleton) .
NE.group . List.sort $ names
unless (null dups) $
Left $ "duplicated metric " ++ renderNames dups
resolveAccessors names
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
next

* Remove a use of the partial `head` function within `criterion`.

1.6.2.0

* Require `optparse-applicative-0.18.*` as the minimum and add an explicit
Expand Down

0 comments on commit e1ae3f3

Please sign in to comment.