import Data.Lensimport Data.Traversable-- | Given a Traversable of entities and a lens for them, normalize-- | over lens getter so that the value of lens setter is in range [0,-- | 1].normalizeLens :: forall a t. Traversable t => Lens' a Number -> t a -> t anormalizeLens l ns = over traversed normalize' ns where values = over traversed (_ ^. l) ns vMin = minimum values vMax = maximum values vRange = do minv <- vMin maxv <- vMax pure $ maxv - minv