目的
Haskellの実装のパターンと応用例の収集。(個人的なメモ)
パターン
実装パターン | 説明 | 実装例 |
---|---|---|
Monoid | 単位元(空白文字とか)と結合があるもの | 文字列の結合 |
Semigroup | 結合があるもの | |
Monad | ユーザーによる拡張可能な状態・変数を持った手続型のプログラミングを可能にするもの | do記法、Maybeモナド、Stateモナドなど。 |
Monad Transformer | モナドの上に異なるモナドを乗せるもの | IOモナドにStateモナドを被せるとか。 |
Reader Monad | ||
Writer Monad | ||
State Monad | ||
Continuation Monad | ||
Free Monad | ||
Indexed Monad | ||
Graded Monad | ||
Comonad | Monadの双対 | Zipper、他の例(Lensなど) |
Applicative | ||
Arrow | Monadが出力の型を持っているのに対して、入力の型も持っているもの | Functional Reactive Programming,デジタル回路 |
Functor | 何らかの入れ物に入ったデータ型を変換するもの | MapReduceのMap |
BiFunctor | ||
Profunctor | Box | |
Foldable | Reduceの一般化 | 配列の合計、最大、最小などの集計 |
Traversable | ||
Lens/Optics | ||
Contravariant | Functorの逆 | ログの出力のフォーマット変換 |
Yoneda | Fusion | |
CoYoneda | ||
Representable | テンソルのブロードキャスト | |
GHC.Generics |
ToDo
- Stackageからの応用例の収集