Some more functions and instances

quickdudley
Feb 9, 2022, 1:56 AM
XC2IMMSVT6OLWXL65BF4RRE2WUB74ETSTGGYQ6ZUZ5RO5YCJGUBAC

Dependencies

Change contents

  • replacement in src/Math/ParetoFront.hs at line 1
    [4.39][4.0:49]()
    {-# LANGUAGE DerivingVia, StandaloneDeriving #-}
    [4.39]
    [4.40]
    {-# LANGUAGE DerivingVia, GeneralizedNewtypeDeriving, StandaloneDeriving #-}
  • replacement in src/Math/ParetoFront.hs at line 10
    [4.35][4.107:118](),[4.107][4.107:118]()
    getFront
    [4.35]
    [4.66]
    getFront,
    quota,
    nestedFold
  • replacement in src/Math/ParetoFront.hs at line 18
    [4.197][2.0:40]()
    import Data.Semigroup(Max(..), Min(..))
    [4.197]
    [4.75]
    import Data.Semigroup(Arg(..), Max(..), Min(..))
  • replacement in src/Math/ParetoFront.hs at line 25
    [4.122][3.153:207]()
    -- | Where the items are equal by all used criteria
    [4.122]
    [4.122]
    -- | Where no item is preferred by any used criterion
  • edit in src/Math/ParetoFront.hs at line 65
    [4.880]
    [4.880]
    instance Debatable a => Debatable (Arg a b) where
    weigh (Arg a _) (Arg b _) = weigh a b
  • replacement in src/Math/ParetoFront.hs at line 83
    [3.519][4.998:1042](),[4.998][4.998:1042]()
    newtype Front a = Front [a] deriving (Show)
    [3.519]
    [3.520]
    newtype Front a = Front [a] deriving (Foldable, Show)
  • edit in src/Math/ParetoFront.hs at line 89
    [4.130]
    [4.1042]
    instance Foldable Strata where
    foldMap f (Strata l) = foldMap (foldMap f) l
  • edit in src/Math/ParetoFront.hs at line 142
    [4.1196]
    [4.1196]
    -- | Drop fronts after those accounting for the first n items.
    quota :: Int -> Strata a -> Strata a
    quota _ (Strata []) = Strata []
    quota n (Strata (a:r))
    | n > 0 = let
    Strata r' = quota (n - length (getFront a)) (Strata r)
    in Strata (a : r')
    | otherwise = Strata []
    -- | 'foldMap' each front separately with one function, then 'foldMap' the
    -- results.
    nestedFold :: (Monoid m, Monoid n) => (a -> m) -> (m -> n) -> Strata a -> n
    nestedFold f g (Strata l) = foldMap (g . foldMap f) l