Traversal,Fold,MonadicFold,Actionに関して

Haskellのlensの使い方 (詳しめ)の続き ちょっとだけ

Lens で Haskell をもっと格好良く! for 2013/3/31 ekmett 勉強会 ちゅーん

Fold

type Fold s a = forall f. (Contravariant f, Applicative f) => (a -> f a) -> s -> f s
folded :: Foldable t => Fold (t a) a
foldMapOf :: Monoid m => Fold s a -> (a -> m) -> s -> m
view :: Monoid m => Fold s m -> s -> m

A Fold s a is a generalization of something Foldable.

A Fold describes how to retrieve multiple values in a way that can be composed with other LensLike constructions.

  • Foldableの一般化
  • Applicative制約はエラーメッセージとかの都合であって本質的ではない
  • Contravariantは反変関手
  • 任意のGetterFold

参考


haskellのlensの使い方 (やばめ)

  • Sun Jun 21 01:52:37 JST 2015
    • もっと詳しく書きたす予定だったけど、たぶんその機会はないので修正