简体   繁体   English

了解Eta减少

[英]Understanding of Eta reduce

When running hlint over the weightDelta function is keeps suggesting Eta reduce. 当在weightDelta函数上运行hlint时,会继续建议减少Eta。 I read another related Eta reduce question , but I can't seem to transfer the understanding into this case. 我读了另一个相关的Eta reduce 问题 ,但我似乎无法将理解转移到这个案例中。

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? 哪里有变化,是否存在任何直觉或伎俩以避免将来减少eta减少的建议?

You won't get it to point- free syntax easily, but what you can do immediately is just η-reduce the ws away. 你不会轻易地得到点语法,但你可以立即做的只是η-减少ws

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. 但这是值得商榷的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM