我想写:
minimum $ map _x elems
使用镜头。我想使用minimumOf
镜头,但我无法从它的类型中弄清楚如何使用它。
我正在寻找类似的东西
elems ^.. minimumOf x
但它不输入检查:
Prelude Control.Lens Data.Map> let elems = [(1,2),(3,4)] :: [(Double, Double)]
Prelude Control.Lens Data.Map> elems ^.. minimumOf _1
<interactive>:62:11:
Couldn't match type ‘Maybe a0’
with ‘[(Double, Double)]
-> Const (Data.Monoid.Endo [a]) [(Double, Double)]’
Expected type: Getting (Data.Monoid.Endo [a]) [(Double, Double)] a
Actual type: (a -> Const (Data.Monoid.Endo [a]) a) -> Maybe a0
Relevant bindings include it :: [a] (bound at <interactive>:62:1)
Possible cause: ‘minimumOf’ is applied to too many arguments
In the second argument of ‘(^..)’, namely ‘minimumOf _1’
In the expression: elems ^.. minimumOf _1