While in examining binding article, we start from bind operator, then convert it to do notation. This article start from do, and revert it back to monadic code using a few operator.
I also add Kleiski Fish Operator, that is very useful as a shortcut in a do notation.
Explaining Monad
This tutorial/ guidance/ article is one of some parts.

Overview: Summary.

References: About Monad.

Examining Bind: Bind
>>=
operator. Hello World Example. 
Examining Bind:
<*>
and<$>
operators. Personal Notes. Example using Number. 
Monadic Operator: Fish
>=>
operator.
The first one is overview, then some references. The last three parts is all about Example Code.
Processing Symbol
I you need to know more about operator,
you can just ask hoogle
.
And if you are curious for another operator, you can read this article and have fun.
Monadic Action
Reference about then >>
operator
and bind >>=
operator can be found here.
Function
Think Function in Haskell as Math Equation
Suppose we have this very short function.
Action
Think Action in Haskell as Procedure, Sequence of Command
We can rewrite this as an action
Then Operator
Removing the do
special notation,
we can desugar the greetingAction
using then >>
operator as below.
Writing it oneliner, would make this action looks exactly like a function. And in fact, it is just a function.
then >>
operator is
just like bind >>=
operator,
except it ignore input.
We need other example containing input.
do
notation does avoid coding horror,
but sooner or later we need to know what is inside.
Bind Operator
Consider this action.
Each command has a Maybe String
result type.
We can desugar the action above
into vanilla monadic code without do
:
Or you can make it oneliner vanilla monadic code.
Here is another IO example, showing you home directory.
There is also good example here
Operation inside Bind
Monads is way to unwrap stuff, do something about it, and wrap the result. Or better, Monad give access for method, to work inside wrapped stuff, without unwrapping it.
This list, will show Monad is overloaded for different types. Every monad has its own implementation.
This will display
It can be desugared into oneliner vanilla monadic code.
The Monad Class
It is clear that sequence command in do notation is
just functions chained together
by bind >>=
operator
or then >>
operator.
Now the next question. What is these two operators has to do with monad ? So here it is the definition of monad in Prelude 4.9.1.0
Those two are Monad Operators.
Monadic Composition
What other practical used, Monads are good for?
There are many I guess. One of them is Kleiski Arrow.
Kleiski Arrow does function composition, just like .
,
except it perform monadic effects.
Reference about Kleiski Arrow >=>
and <=<
operator can be found here.
I looks like fish, so we can call this fish
operator.
Function
Consider this function
We can avoid closing bracket
using function application $
.
Or we can join two function
using function composition .
.
Action
Consider this action
Since the output is IO String
, while expected input type
from puStrLn
is String
.
The composition have to be Monadic. Kleiski Arrow perform this well.
Or Kleisli Composition, using reversed arrow.
Thank you for Reading.
Archives
 July 2017
 June 2017

May 2017
 Examining Bind in Haskell: Example using Number
 Examining Bind in Haskell: Hello World
 Explaining Monad: References
 Explaining Monad: Overview
 Loop in Haskell With Map, Part Three
 Loop in Haskell With Map, Part Two
 Loop in Haskell With Map, Part One
 Loop in Haskell With Map, Overview
 Modularized HerbstluftWM in Haskell
 Modularized HerbstluftWM in Lua
 Modularized HerbstluftWM in PHP
 Modularized HerbstluftWM in Ruby
 Modularized HerbstluftWM in Python
 Modularized HerbstluftWM in Perl
 Modularized HerbstluftWM in BASH
 Modularized HerbstluftWM Overview
 April 2017