Understanding Eta Reduce

When you run hlint over the weightDelta function, the Eta suggestion is reduced. I read another Eta question related to this, but I cannot convey an understanding of this matter.

 module StackQuestion where import qualified Data.Vector as V type Weights = V.Vector Double type LearningRate = Double weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights weightDelta nry ws = V.map update ws where update w = diff * n * w diff = r - y 

Every change that I try to make to "reduce" it to indicate free syntax just breaks it. Where changes should be made, and is there any intuition or trick to avoid eta's suggestions in the future?

+4
source share
1 answer

You cannot easily get the syntax without specifying a point, but what you can do right away is to simply reduce ws .

 weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights weightDelta nry = V.map update where update w = diff * n * w diff = r - y 

You can also do something like

  where update = (δ *) δ = n * (r - y) 

but this is pretty controversial.

+8
source

All Articles