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

タグ

haskellとfunctorに関するigrepのブックマーク (4)

  • GHC Generic Programming と代数的データ型 - khibino blog

    Haskell Advent Calendar 2016 の 12日目のエントリーです。 代数的データ型と Functor Generic Programming は代数的データ型の構造を Functor の直積と直和のネスト構造に対応付けることで、 任意の代数的データ型に対する操作の記述を可能にする仕組みです。 まずは理解のために、より単純化した構造で考えてみましょう。 次のようなデータ型 ProdF f g a を考えると、 ProdF f g は Functor f および Functor g のもとで Functor になります。 これは、 もとの Functor のそれぞれの像の直積も Functor になる ということです。 ほぼ自明な内容ですが、 functor則を満たしていることを下に簡単に示してあります。 data ProdF f g a = ProdF (f a) (g

    GHC Generic Programming と代数的データ型 - khibino blog
  • Applicativeのススメ - あどけない話

    この記事の目的は、Applicative 信者による Applicative スタイルの布教です。 簡潔に結論を述べると、 foo = do a <- m1 b <- m2 return (f a b) のようなコードを書きたくなったら foo = f <$> m1 <*> m2 と書きましょうということ。 合い言葉は、「do と return をなくせ!」です。 FunctorとMonadの間 Functor を特殊化した型クラスがMonadで、Monadの方が強力です。なぜなら、メソッドが増えるからです。 Functorのメソッドはfmapです。fmapの別名を (<$>) といいます。(この記事では、(<$>) と liftM を同一視します。) そして、Monadのメソッドは、ご存知の通り (>>=) と return です。 FunctorとMonadの間にApplicative

    Applicativeのススメ - あどけない話
    igrep
    igrep 2016/05/15
    ブクマしてなかった。今はもうこの記事で言うところの理想化された世界になったからいいよね!
  • The functor design pattern

    This post builds on my previous post on the category design pattern and this time I will discuss the functor design pattern. If you are an intermediate Haskell programmer and you think you already understand functors, then think again, because I promise you this post will turn most of your preconceptions about functors on their head and show you how functors are much more powerful and generally ap

    igrep
    igrep 2015/03/15
    昨日これ読んで思ったんですがもしかして全てのCategoryはMonoidなんでしょうか...?CategoryはMonoidより広い概念?=>逆だった。MonoidはCategoryやった
  • SetはFunctorである - think and error

    Haskell Advent Calendar 2013 9日目です。 概要 SetはFunctor。 Categorical Programming for Data Types with Restricted Parametricity rmonad: Restricted monad library なぜSetはFunctorになっていないのか Setを要素が重複しないデータ構造とします。Setはその性質のため、要素には比較出来ることが要求されます。Haskellで言うとEq制約です。まあ来重複しないことだけを要求するならEq制約だけでいいはずですが、SetがOrd制約を要求しているのは効率の良い実装にするためでしょう。containersパッケージのData.Setはバランス二分木で実装されています。 来SetはFunctorにすることが出来るはずです。しかし現状(GHC7.6

    SetはFunctorである - think and error
  • 1