- 箱で考えるFunctor、ApplicativeそしてMonad
- Grasping Haskell: functors, applicatives and monads (Part 1)
- Grasping Haskell: functors, applicatives and monads (part 2)
- Briefly on the purpose of Functors, Applicatives and Monads
- An Intuition on Context I
- An Intuition on Context II
- HaskellのFunctorとApplicativeFunctorとMonad
- Functors, Applicatives, and Monads
- Typoclassopedia: Exercise solutions
- Functor, Applicative and Why
- Notions of Computation as Monoids
関手 - Functor
class Functor f where
fmap :: (a -> b) -> f a -> f b
- Loop School - Functors
- Loop School - Natural Transformations
- ファンクタであそぼう
- Monads and more
- なぜ初心者にHaskellのファンクターは怖いと言われるのか(翻訳)
- A functor is not a box
- George Wilson - The Extended Functor Family - YouTube
- Making your brain tingle: Functions as functors · Waste of Time
- rampion/conkin - Tools for functors from Hask^k to Hask
- Functor Functors
- Deriving not-so-complex types – Techscape
- Functor-Of
- The Functor Combinatorpedia · in Code
- 関数型プログラミングのFunctorって何が嬉しいの? - Qiita
- 関数型プログラミング -Applicativeについて知る前に、Functorでできないことを知っておこう- - Qiita
- Functorに触れてみよう - Qiita
- Enhancing Functor Structures Step-By-Step (Part 1) · in Code
- Enhancing Functor Structures Step-By-Step (Part 2) · in Code
Bifunctor
Profunctor
- profunctor
- Phil Freeman - Fun with Profunctors
- Profunctor Polymorphism
- Addressing Pieces of State with Profunctors
- Profunctors, Arrows, & Static Analysis
- Profunctors for encoding and decoding | Avoltus
- Profunctors
Contravariant
- contravariant
- Covariance and Contravariance
- Contravariance and luminance to add safety to uniforms
- Contravariant functors are Weird
- MuniHac 2020: Duncan Coutts - Contravariant Logging: How to add logging without getting grumpy - YouTube
Representable Functor
class Functor f => Representable f where
type Log f
lookup :: f a -> (Log f -> a)
tabulate :: (Log f -> a) -> f a
-- 米田の補題によりtabulateと同型
positions :: f (Log f)
tabulate h = fmap h positions
positions = tabulate id
- The Comonad.Reader » Representing Applicatives
- Data.Functor.Rep
- Radix Sort, Trie Trees, and Maps from Representable Functors
- Memoizing polymorphic functions via unmemoization
- Memoizing Polymorphic Functions with High School Algebra and Quantifiers
- APLicative Programming with Naperian Functors
- naperian tensors
- Radix Sort, Trie Trees, and Maps from Representable Functors
Applicative
class Functor f => Applicative f where
pure :: a -> f a
(<*>) :: f (a -> b) -> f a -> f b
- HaskellのApplicativeについて[基本編] - Qiita
- HaskellのApplicativeについて[発展編] - Qiita
- 関数型プログラミング-Applicativeって何が嬉しいの?- - Qiita
- Applicative Programming with Effects / 元論文
- Applicative functor - PS / lax monoidal functor
- Applicative Functors with Strings
- アプリカティブ関手ってなに?モノイド圏との関係は?調べてみました! | 雑記帳
- Haskell Applicative Functors Explained Without Words
- Applicative Archery - The Life Monadic / Applicative則
- Applicatives in Math vs Code
- Applicative Functors and data validation | Codurance
- Applicative Functors and data validation, part II | Codurance
- An Applicative for Transactional Validation - Lumi Engineering
- The Const Applicative and Monoids · in Code
- Selective applicative functors | no time / Applicative と Monad の間
- Haskell for all: Co-Applicative programming style
Day convolution
- Free Monoidal Functors, Categorically! | Bartosz Milewski’s Programming Cafe
- Functorial Blog - Co Finds a Pairing
Free Applicative
- [1403.0749] Free Applicative Functors
- ZedneWeb: Free Applicative Functors in Haskell
- ZedneWeb: More on Free Applicative Functors
- jaspervdj - The Prio Applicative
Discrimination
- discrimination
- ZuriHac 2015 - Discrimination is Wrong: Improving Productivity
- ekmett先生のdiscriminationというライブラリの動画を見たので雑に要約してみた - xuwei-k’s blog
- Radix sort
- Why does
sort
in Data.Discrimination claim to be O(n)? - mysterious-incomposability-of-decidable
自然変換
type (~>) f g = forall x. f x -> g x
- The natural-transformation package
- 3 06 Synthesis with String Diagrams in Haskell
- length は リスト函手から定数函手への自然変換だよ on Coq.
- Fast total sorting of arbitrary Traversable containers
モナド
「環」の理論を知らなくても整数の足し算掛け算が出来るように、モナドの数学的な側面を知らなくてもモナドを使うことは出来る。
盲目の男たちがいました。彼らは象を知ったばかりでした。
1人は「あれば大木だ」と両足を腕で包みながら言いました。
もう1人は「あれば大蛇だ」と胸を包みながら言いました。
3人目の男は「うーん」と言いながら、ほうきか扇か何かを想像しました。
出典: モナドは象だ
まずは、型クラスと高階関数を使ってプログラムを書いてみてください。そうすれば、モナドは自然と使えるようになるよ、というのが今日の私の主張です。
出典: 初心者のモナド
class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> b
- モナドって何だろうか | その他ブログ
- モナドのすべて
- 難しいのは見た目だけ!?Haskellのモナドの「たった2つのルール」を簡単に理解する!
- Monads to Machine Code (Part 1)
- Maybeモナドの使い道 部分的な失敗を全体的な失敗とする計算(1)
- Eitherモナドの使い道 部分的な失敗を全体的な失敗とする計算(2)
- モナモナ言わないモナド入門
- 函数プログラミングの集い2011チュートリアル「モナドについて」
- 3 Approaches to Monadic API Design in Haskell
- モナドはポケモン。数学が出てこないモナド入門
- モナドはなぜHaskellでしか積極的に使われていないのか?
- モナドの六つの系統[Functor x Functor]
- だんだんわかる モナド入門 (Haskell)
- Haskellでmain(do)内での”<-“と”let”の違い
- いろんなMonadをdo構文で
- わーい、すごーい、モナドがたくさんあるねー! - Qiita
- [Haskell]結局、モナド則は何を要求しているのか - Qiita
- モナドを使ったモノイドのインスタンス - Qiita
- Monads for Go Programmers
- Making your brain tingle: Explaining Monads · Waste of Time
- 作って理解する Haskell の Monad - Qiita
- Haskell副作用ポエム - Qiita
- モナド則とプログラミング - Qiita
- なぜモナドが必要なのか? - Qiita
- [Haskell] 爆速でモナドを理解する - Qiita
- HaskellのMonadお気持ちチュートリアル - Qiita
- 二分木をモナドにする - Qiita
- モナドって結局何なのよ? — join to Monad v0.1.3 documentation
- 具体的な値でモナド則を確認する - Maybe編 - Qiita
- 具体的な値でモナド則を確認する - List編 - Qiita
- Selectionモナド入門 - Qiita
- モノイドとモナドの対応関係 - Qiita
- Why Do Monads Matter?
- All About Monads
- Monad tutorials timeline
- Loop School - Monads
- Loop School - F-Algebras Part1
- Loop School - F-Algebras Part2
- Loop School - F-Algebras Part3
- What a Monad is not
- Fixing the Monad instance for Either
- Finally Understand Monads with this One Weird Trick
- 06 Automatically escaping Monads - YouTube
- DefaultSignaturesを用いたMonadの理想的な定義
- Haskell Monads Explained Without Words
- A short recap of monads
- If monads are about syntax then algebras are about semantics
- An initial solution to the monad problem, and then some more
- The Monad Challenges
- CSE230 Wi13 - Programming With Effects II
- Railway Oriented Programming
- The five arguments on why people struggle with monads
- Why do we need Monad to encapsulate side effects in Haskell?
- Monads are like Lannisters
- The Key Monad: Type Safe Unconstrained Dynamic Typing
- Supermonads: One Notion to Bind them All
- Kleisli Functors
- Monads: Programmer’s Definition
- Day 3: Maybe — Mini-Lists, or Mini-Exceptions
- Strict Identity Monad
- Monads Made Difficult
- Predicate Monads: A Framework for Proving Generic Properties of Monadic Programs via Rewriting - POPL 2017
- Three Useful Monads
- Comprehending Monad
- Value recursion in monadic computations
- Monads from Comonads, Comonads from Monads
- Codensity Monad
- Constrained monads
- From Imperative to Pure-Functional and Back Again: Monads vs. Scoped Continuations
- Monads need not be endofunctors
- Burritos for the Hungry Mathematician
- Free Monad
- Monads by Example
- Implementing a category-theoretic Hask-monad in Haskell
- 24 days of Hackage, 2015: day 11: monad-loops: avoiding writing recursive functions by refactoring
- The Monad Fear - LINE Haskell Boot Camp
- Abstract Nonsense
- 安安的異想世界 - Monads in Category Theory for Laymen
- Haskell Exists: Ten example uses of Monads
- basvandijk/monad-batcher: An applicative monad that batches commands for later more efficient execution
- kvanberendonck/monad-chrono: A strict state monad with a notion of time travel.
- 2017 02 08 - Ben Lippmeier - An overview of the DDC compiler - YouTube
- Partial patterns in do blocks: let vs return
- Obey the (Type) Laws!
- A Logical Relation for Monadic Encapsulation of State Proving contextual equivalences in the presence of runST
- Badness 10.0000 | Escaping Hell with Monads
- Monads in Minutes
- Monadic “do” block, yet again – Techscape
- What is a Monad? - Computerphile - YouTube
- Papers We Love San Diego - Monads for Functional Programming - YouTube
- Haskell: Monadクラスのこれまでとこれから - Qiita
- Burritos for the Hungry Mathematician
- Dan Ghica’s Blog: Haskell: If monads are the solution, what is the problem?
- A Basis For Sequential Execution: Monads, Arrows, and More | Aearnus’ Realm
- [1903.01237] Dijkstra Monads for All
- Monads as a Programming Pattern
- Lysxia - A monad is just a submonad of the continuation monad, what’s the problem?
- Neil Mitchell’s Haskell Blog: Monads as Graphs
- いろいろなモナド at Nakameguro.hs #2 - Qiita
- モナドプログラミング - Qiita
- モノイドとモナドの対応関係 - Qiita
- Oleg’s gists - overloaded-0.2.1: Overloaded:Do
- 具体例から学ぶモナド再入門 - Qiita
- Tweag - Qualified do: rebind your do-notation the right way
- モナドオリンピック1-トラック競技-
- Functors and Monads For People Who Have Read Too Many “Tutorials” - iRi
- もう諦めない圏論入門―モノイドからモナドへ― - Qiita
- Monads are just monoids in the category of endofunctors
- 関数型言語におけるMonadクラスはApplicativeを継承するべきなのか?MonadとApplicativeとの関係を再確認する - Qiita
do x <- mx
y <- my
z
-- ... desugars to:
mx >>= (\x ->
my >>= (\y ->
z ))
出典: How to desugar Haskell code
Maybe Monad
Either Monad
List Monad
instance Monad [] where
return x = [x]
xs >>= f = concat (map f xs)
- リストモナドの動作原理を考える
- 非決定計算としてのリストモナド
- guard の動作原理を考える
- Easy exhasutive search with the list monad
- Day 2: [] — Seeing the rest of a program run
- How the List Monad helped me better understand Non-deterministic Polynomial time complexity
- A Very Small SAT Solver
- Fractals and Monads | Simplicity
- Fractals and Monads – Part 2 | Simplicity
- Fractals and Monads – Part 3 | Simplicity
- リストモナドについて - Qiita
LogicT
- リストモナドとLogicモナド
- LogicT
- Backtracking, Interleaving, and Terminating Monad Transformers
- The logict package
- BACKTRACKING, INTERLEAVING, AND TERMINATING MONAD TRANSFORMERS
- /usr/sbin - Expanding Regular Expressions with LogicT
Reader Monad
newtype Reader e a = Reader { runReader :: (e -> a) }
instance Monad (Reader e) where
return a = Reader $ \e -> a
(Reader r) >>= f = Reader $ \e -> runReader (f (r e)) e
- Reader monad
- Dependency InjectionとDSL
- Quick interpreters with the Reader monad
- Haskellで大域変数が欲しい時はReaderモナドを使いましょう
- Reader monad and SKI combinators
- haskell - What’s the difference between Monad.Reader and the (->) monads? - Stack Overflow
- Deriving the Reader monad from first principles | William Yao
- 順を追って理解する Reader モナドの使い方
- That One Cool Reader Trick
Writer Monad
随伴
今回は話の中でいきなりWriterとReaderが出てきて、この2つで随伴になると説明しましたが、実際はStateモナドやStoreコモナドからこの2つの関手を導くことができますです。 随伴がモテないのはどう考えてもモナドが悪い!(モナドとコモナドの関係が分かる話)
- Haskellと随伴
- From Adjunctions to Monads
- When does an endofunctor derive from an adjunction?
- From mathematics to map-reduce
- Adjunctions in the wild: foldl · in Code
- 随伴関手とは - Qiita
State Monad
newtype State s a = State { runState :: s -> (a, s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)
m >>= k = State $ \s ->
let (a, s') = runState m s
in runState (k a) s'
- Stateモナドによるポーランド記法の処理
- Stateモナドによる逆ポーランド記法の処理
- Stateモナドによる中置記法の処理
- Haskellでスタックを利用した加減乗除の計算機を作ってみる
- Haskell has no state monad
- Stateモナドが便利に使えた!
- How does the State monad work?
- Wrangling State In Haskell
- Universally stateless monads
- Stateモナドを理解する - Qiita
- HaskellのStateの必要性が,プログラミング言語の処理系を書いた時にわかったので,Stateの良さを語ります
- Stateモナドを数学的に実装する - Qiita
- Turning bottom-up into top-down with Reverse State - ielliott.io
- The Curious Time-Traveling Reverse State Monad
- 世界一わかりやすいStateモナドのしくみ、あるいは猫でもわからないモナドのおはなし - Qiita
- Update Monads: Variation on State Monads
- 逆状態モナド - Qiita
-
[Deriving the State monad from first principles William Yao](https://williamyaoh.com/posts/2020-07-12-deriving-state-monad.html)
RWS Monad
Reader + Writer + State
ST Monad
- HaskellにおけるIOモナドとSTモナドの関係
- Performance of the ST Monad with pure exceptions
- Imperative Haskell - Vaibhav Sagar
- Having your cake and eating it – Permutive – Medium
- mutable - Home
- Immutability, Docker, and Haskell’s ST type
IO Monad
- IO is Your Command Pattern
- How Haskell models IO
- IO inside
- Notions of computation and monads
- How to Declare an Imperative
- GHC 以外の処理系での IO 型/IO モナドの実装
- Zhuangzi, butterfly and referential transparency
- Effectful Haskell: IO, Monads, Functors
- On the unsafety of interleaved I/O
- Haskell ポインタープログラミング
- Imperative bits of Haskell
- 純粋関数型JavaScriptのつくりかた
- Making sequence/mapM for IO take O(1) stack
- Extra unsafe sequencing of IO actions
- The unexceptionalio package
- C#/Javaで読む、HaskellがIOモナドで実現したいこと
- ノンブロッキングI/Oと非同期I/Oの違いを理解する
- Pure API vs. IO-bound API for graphics frameworks
- A newcomer’s run-in with lazy I/O
- IO Monad Considered Harmful
- Day 1: IO — Our Ugly Friend
- Sneaky Implicit Mutation – Fintan Halpenny – Medium
- sketches/ann-monad-var at master · effectfully/sketches
- Scheduling Effects - Donnacha Oisín Kidney
- HANGMAN: IMPERATIVE FUNCTIONAL PROGRAMMING
- stdio - A simple and high-performance IO toolkit for Haskell | Winter’s Land
- 続くといいな日記 – GHC IO モナドの中身
- HaskellのファイルIO
- IO and monads
- IO モナドと副作用 - Haskell-jp
- The power of IO in Haskell | 47 Degrees
- How Accursed and Unutterable is accursedUnutterablePerformIO?
- (λblog.rainbyte) - Haskell from 0 to IO (Maybe Hero)
乱数
- Haskell Bits #1: Randomness - Benjamin Kovach
- Random Benchmarks | Alexey Kuleshevich
- Tweag - Splittable pseudo-random number generators in Haskell: random v1.1 and v1.2
- New random interface | Alexey Kuleshevich
Monad*
MonadFail
MonadPlus
- MonadPlus and Monoid serve different purposes.
- MonadPlus and Alternative are just near-semirings in the category of endofunctors, what’s the problem?
returnWhen
for MonadPlus- Adventures in Looping
MonadBase
MonadIO
MonadThrow
MonadCatch
MonadMask
MonadFix
Indexed Monad
- What is indexed monad?
- Indexed Monadの世界
- Motor: Finite-State Machines in Haskell | Func Da World
- モナドの新しい力!スーパープリキュアモナド! ~タイプセーフプリキュア!を支える技術 その4~
- Using the Indexed State Monad and Dependent Types to represent a Game of Texas Hold ‘Em – Santi’s Blog
- Indexed Monads
- Type level mapを使ったpreload風関連リソースの取り回し。Indexed monad添え
Super Monad
Arrow
- Haskell/Arrows - Wikibooks
- ArrowによるHaskellプログラミングの基礎。…パイプ感覚で順次/分岐/繰返し - よくわかりません
- Arrowパズル解答 (とArrowLoop解説)
- ArrowLoop - 言語ゲーム
- Arrowの話をしよう (2)不動点と再帰 - haxis_fxの日記
- Bartosz Milewski - Arrows are strong profunctors
- Higher-order abstract syntax for any CCC!
- Arrowを理解する - Qiita
- ZedneWeb: Arrow is more than Strong and Category
- Haskell におけるモナドとアローの同値性
- Haskell/Understanding arrows - Wikibooks, open books for an open world
- jaspervdj - Visual Arrow Syntax