在weightDelta
函数上运行 hlint 时,会不断提示 Eta reduce。我阅读了另一个相关的 Eta reduce question,但我似乎无法将理解转移到这个案例中。
module StackQuestion where
import qualified Data.Vector as V
type Weights = V.Vector Double
type LearningRate = Double
weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights
weightDelta n r y ws = V.map update ws
where update w = diff * n * w
diff = r - y
我试图“减少”它以指向自由语法的每一次更改都会破坏它。要在哪里进行更改,是否有任何直觉或技巧可以避免将来出现 eta reduce 建议?