4

私は書きたい:

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
4

1 に答える 1