When running hlint over the weightDelta
function is keeps suggesting Eta reduce. I read another related Eta reduce question , but I can't seem to transfer the understanding into this case.
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
Every change I try to make to "reduce" it to point free syntax just breaks it. Where's the change to be made, and is there any sort of intuition or trick to avoid an eta reduce suggestion in the future?
You won't get it to point- free syntax easily, but what you can do immediately is just η-reduce the ws
away.
weightDelta :: LearningRate -> Double -> Double -> Weights -> Weights
weightDelta n r y = V.map update
where update w = diff * n * w
diff = r - y
You can also do something like
where update = (δ *)
δ = n * (r - y)
but that's rather debatable.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.