更新された html5版があるので、よろしくお願いします。
reynaldo f. tamayo for openphoto.net
11日目には入れ子になった不変データ構造へのアクセスする方法を抽象化したものとしての Lens をみた。
今日は論文をいくつか飛ばし読みしてみよう。まずは Jeremy Gibbons さんの Origami programming だ。
Origami programming
Gibbons さん曰く:
In this chapter we will look at folds and unfolds as abstractions. In a precise technical sense, folds and unfolds are the natural patterns of computation over recursive datatypes; unfolds generate data structures and folds consume them.
foldLeft
は 4日目に Foldable
を使ったときにみたけど、unfold って何だろう?
The dual of folding is unfolding. The Haskell standard List library defines the function unfoldr
for generating lists.
Hoogle には以下の例がある:
Prelude Data.List> unfoldr (\b -> if b == 0 then Nothing else Just (b, b-1)) 10
[10,9,8,7,6,5,4,3,2,1]