Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

タグ

関連タグで絞り込む (1)

タグの絞り込みを解除

monadに関するnobu-qのブックマーク (2)

  • Monads are Trees with Grafting

    Monads are Trees with Grafting Dan Piponi A Neighborhood of Infinity January 1, 2010 1 Goals and Prerequisites This article is intended to give an elementary introduction to an aspect of mon- ads not covered in most introductions. The reader is expected to know some basics of Haskell, for example what a type class is and what a lambda term is. They are also expected to be familiar with the usual n

  • Stateモナドを絵を描いて理解してみた - oto-oto-oto’s diary

    絵を描きながらStateモナドを考えてみたら意外とうまくいったので紹介します。 Stateモナドには「表の値」と「裏の値=状態」という2つの値(型)が登場します。 Stateモナドの定義です。(s -> (a,s))で、sが状態の型、aが表の値の型です。 newtype State s a = State { runState :: (s -> (a,s)) } The State monad 図の方ですが、矢印は関数です。原則として、1入力1出力の一の矢印で表しますが、今回は戻り値が2値のタプルなので2出力として書きました。 丸四角で囲ってあるのは、関数をオブジェクト*1として扱うことを意図しています。 これに対して、丸四角で囲っていない矢印は関数適用を表すことにします。 一番外側の大カッコはStateモナドのデータ構築子を表します。これでラムダを囲むとStateモナドの値になります。

    Stateモナドを絵を描いて理解してみた - oto-oto-oto’s diary
  • 1