A Fistful of Monads

Kotlin Monad (and Functor, Applicative)

1. Functor “map” (Kotlin) (fmap or <$> in Haskell)

https://hackernoon.com/kotlin-functors-applicatives-and-monads-in-pictures-part-3-3-832d58d92445

2. Monadsflatmap” (>>= in Haskell)

Haskell Monad:

http://learnyouahaskell.com/a-fistful-of-monads

Do not fear Monoid / Monoidal Category / Monad:

Monad in Haskell

F# Monad:

View story at Medium.com

(分享自知乎网)

https://zhuanlan.zhihu.com/p/29542641

Advertisements

Monads 单子(Dr. Eugenia Cheng)

Dr. Eugenia Cheng ‘s Lectures on Category Theory (2007)

1. Definition of Monad,  Example: Monad for Monoids

The name “monad” came from “monoid” and “triad”, which indicated that it is a triple (1 functor + 2 trasformations), monoidic algebraic structure.

Monad = Monoid + Triad

Monad = Monoid (restricted to endofunctors)

Note: She was annoyed nobody had corrected her mistake in (red) Tμ . (I discovered it only on 2nd revision view few years later).

2. Example2: Monad for Categories

Monad for Small Categories (= Set)

3. Algebra = Monad 

 

Ref: 

https://tomcircle.wordpress.com/2017/04/28/monoid-and-monad/

What is the difference between Monoid and Monad? (Bartosz Milewski )

Monad (图解)  : 单子
Functor: 函子

Program = Category 

2017 : (PhD Math made simple for IT programmers)

Keywords

  • Category 
  • Monad = Monoid + Endofunctor
  • Lewvere Theory

Category Theory is replacing Set Theory as the foundation of Math. Nowadays,  few Advanced Math papers are written without using Category to explain, and this trend is spreading to IT  through Functional Programming languages (Google’s Kotlin, Haskell, Clojure…)  – the latest paradigm to replace Object-Oriented languages like Java, C++, etc, as a safer “Strong Typed” languages for AI, BIG DATA…

\boxed {\text {Type = Category }}

Examples of “Types” in IT:

  • Integers
  • Real
  • Double
  • Boolean
  • String
  • etc

T-program defined in the following 6 examples: 

  • list (X), eg. {2, 5 , 3, 7, 1 }
  • partial (X), eg: +1 (error msg)
  • side-effect, eg: update a record
  • continuation (X),
  • non-det (X), 
  • prob-dist (X)

A Monad : a T-program which turns an arrow to a “Category” (ie + 2 properties:  Identity &  Associative).

Proof: List Computation is a Category

Proof: Partial operation is a Category

\boxed {\text {Monad = Lawvere Theory }}

Monad is for only one Category. Lawvere Theory is more general.


Ref
:

Slideshttp://www.math.jhu.edu/~eriehl/compose.pdf

Ref:
Excellent Intuitive Stackoverflow Answer:  What is a Monad ?