SlideShare a Scribd company logo
LINE Haskell Boot Camp
The Monad Fear
The Shibuya Camp
Finale
1 / 42
This slide is the presentation material used in the LINE Haskell Boot Camp that took
place in Shibuya, Tokyo, on October 28th, 2016.
The latest version of this slide is available at: https://e.xtendo.org/monad
2 / 42
Fear, Uncertainty, and Doubt
Haskell is difficult to learn
Monad is difficult, and therefore Haskell is difficult
You need to understand monad in order to use Haskell
You need to understand monad in order to use practical Haskell
Haskell is a mathematical language
Anyways you should learn monad
3 / 42
Fear, Uncertainty, and Doubt
Haskell is difficult to learn
Monad is difficult, and therefore Haskell is difficult
You need to understand monad in order to use Haskell
You need to understand monad in order to use practical Haskell
Haskell is a mathematical language
Anyways you should learn monad
None of the above is true.
3 / 42
Not my original idea.
Dan Piponi, The IO Monad for People who Simply Don't Care (2007)
Brent Yorgey, Abstraction, intuition, and the “monad tutorial fallacy” (2009)
tora, My how to give a 'monad tutorial' tutorial (2010)
scottw, Why I won't be writing a monad tutorial (2013)
Travis Hance, Write you a monad tutorial (2014)
~kqr, The "What Are Monads?" Fallacy (2015)
Justin Le, IO Monad Considered Harmful (2015)
The community began to recognize the problem: "Why do so many beginning Haskellers
ask the same (wrong) question and go through the same (unnecessary) difficulties?"
4 / 42
I've been organizing the South Korean
Haskellers' group for nearly a year
The two most frequently asked question from the newcomers:
5 / 42
1. If Haskell is so great, why's nobody
using it?
6 / 42
2. What the hell is monad?
7 / 42
Pedagogical catastrophe
Ask the Internet, "What is Haskell?"
Purely functional
Lazy
Uses monads
Type classes
etc.
8 / 42
Pedagogical catastrophe
Ask the Internet, "What is Haskell?"
Purely functional
Lazy
Uses monads
Type classes
etc.
In short, things that newcomers can't possibly have a clue of.
8 / 42
Pedagogical catastrophe
Ask the Internet, "What is Haskell?"
Purely functional
Lazy
Uses monads
Type classes
etc.
In short, things that newcomers can't possibly have a clue of.
Using things you don't know in order to teach you something you don't know
8 / 42
Pedagogical catastrophe
Ask the Internet, "What is Haskell?"
Purely functional
Lazy
Uses monads
Type classes
etc.
In short, things that newcomers can't possibly have a clue of.
Using things you don't know in order to teach you something you don't know
?!
8 / 42
Pedagogical catastrophe
Ask the Internet, "What is Haskell?"
Purely functional
Lazy
Uses monads
Type classes
etc.
In short, things that newcomers can't possibly have a clue of.
Using things you don't know in order to teach you something you don't know
?!
It would be a miracle if there's no massive frustration.
8 / 42
Why was Haskell created?
9 / 42
Haskell 2010 Report
Preface
[...]
Goals
1. It should be suitable for teaching, research, and applications, including
building large systems.
10 / 42
Haskell 2010 Report
Preface
[...]
Goals
1. It should be suitable for teaching, research, and applications, including
building large systems.
Explicitly stated goal of usefulness in application development.
10 / 42
How the Haskell Committee happened
11 / 42
How the Haskell Committee happened
It is 1987. Non-strict purely functional languages are flooding.
11 / 42
How the Haskell Committee happened
It is 1987. Non-strict purely functional languages are flooding.
Too many choices, redundant independent efforts. None is chosen in the market.
11 / 42
How the Haskell Committee happened
It is 1987. Non-strict purely functional languages are flooding.
Too many choices, redundant independent efforts. None is chosen in the market.
Purely functional seems to be a good idea, and it's a pity it's not used. Let's unite and
create a language that gets chosen.
11 / 42
How the Haskell Committee happened
It is 1987. Non-strict purely functional languages are flooding.
Too many choices, redundant independent efforts. None is chosen in the market.
Purely functional seems to be a good idea, and it's a pity it's not used. Let's unite and
create a language that gets chosen.
In other words, Haskell was not meant to be academia-only.
11 / 42
How the Haskell Committee happened
It is 1987. Non-strict purely functional languages are flooding.
Too many choices, redundant independent efforts. None is chosen in the market.
Purely functional seems to be a good idea, and it's a pity it's not used. Let's unite and
create a language that gets chosen.
In other words, Haskell was not meant to be academia-only.
It was designed to be used in real-life.
11 / 42
Haskell: A practical tool that solves
real-world problems
A web server with higher performance that the ones written in C
Standard Chartered: "real time pricing, risk management, data analysis, regulatory
systems, desktop and web GUIs, web services, algo pricing, end-user scripting"
Facebook's data access tools and antispam tools
Haskell in finances: ABN AMRO, Bank of America, Barclays, Credit Suisse, Deutsche
Bank, Tsuru Capital
12 / 42
FUD
Haskell's I/O is
somehow special/weird/difficult
13 / 42
Haskell
main = do
putStrLn "Hello. What is your name?"
x <- getLine
putStrLn ("The input was " ++ x)
14 / 42
Python
if __name__ == '__main__':
print ('Hello. What is your name?')
x = input()
print ('The input was ' + x)
15 / 42
Do the I/O in Haskell. It works.
There is NOTHING special about Haskell's I/O.
Do it as you did in other (imperative) languages.
Deliberately imperative “look and feel”
Simon Peyton Jones, Wearing the hair shirt: a retrospective on Haskell (2003)
We intentionally made it usable imperatively.
The misconception that Haskell's I/O is difficult/special/weird does NOT come from
people who actually tried it.
One phrase caused all tragedy:
16 / 42
IO monad
17 / 42
IO Monad Considered Harmful
Justin Le:
The phrase “IO monad” considered harmful. Please do not use it.
...
I’m going to say that this is probably the single most harmful and damaging
thing in Haskell ...
18 / 42
IO Monad Considered Harmful
Justin Le:
The phrase “IO monad” considered harmful. Please do not use it.
...
I’m going to say that this is probably the single most harmful and damaging
thing in Haskell ...
?!
18 / 42
Unix commands
echo STRING
cat FILENAME
rm FILENAME
mkdir DIRNAME
echo and cat are commands,
STRING and FILENAME are strings, which are argument for commands.
command and string are different types.
19 / 42
Unix pipe
find . | grep ".txt$"
tail -f app.log | grep "^system:" > output.txt
You want to feed the result output of one command as an input to another
command.
20 / 42
Haskell's command: action
putStrLn :: String -> IO ()
readFile :: FilePath -> IO String
main = do
x <- readFile "myname.txt"
putStrLn ("Hello, " ++ x ++ "!")
Just as echo is a command that takes one string as its argument, putStrLn is an
action that takes one String.
Just as cat takes a file path as its argument and prints its content, readFile is an
action that takes a FilePath and returns its content as a String.
Actions and Strings are different types.
Actions and the ++ operator are also different types.
21 / 42
Haskell's pipe
Haskell's pipe looks like this: >>=
main = readFile "myname.txt" >>= putStrLn
Feed the output of one command as an input of another command.
22 / 42
Haskell distinguishes pure functions
and actions by their types
-- pure function
not :: Bool -> Bool
(++) :: [a] -> [a] -> [a]
-- IO action
getLine :: IO String
putStrLn :: String -> IO ()
readFile :: FilePath -> IO String
23 / 42
Action is easy. Then why?
Just call them "IO action" or "IO type", and explain they are similar to Unix
commands, and there will be nothing more to teach.
But we call them IO monads and cause this chaos.
Bewildering number of beginners are asking "what is monad?" first. (Because when
programmers see a strange jargon, they just have to understand it. It's their instinct)
"How do I deal with a sequence of multiple numbers in Haskell?"
"Use List." or "Use the List type."
No one replies with "Use the List monad" unless they're pure evil!
Therefore the answer to "How do I do the input/output in Haskell" should also be:
"Use the IO type."
24 / 42
Our biggest mistake: Using the scary term “monad” rather than “warm fuzzy
thing”
-- Simon Peyton Jones, Wearing the hair shirt: a retrospective on Haskell
(2003)
25 / 42
Historical background
Since when did Haskell have monads?
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published. No monads.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published. No monads.
1992: The Haskell 1.2 report is published.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published. No monads.
1992: The Haskell 1.2 report is published. No monads.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published. No monads.
1992: The Haskell 1.2 report is published. No monads.
1996: The Haskell 1.3 report is published.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published. No monads.
1992: The Haskell 1.2 report is published. No monads.
1996: The Haskell 1.3 report is published. Monadic I/O is introduced.
26 / 42
Historical background
Since when did Haskell have monads?
1987: The Committee is formed. They chose Miranda as the basis. No monads.
1990: The Haskell 1.0 report is published. No monads.
1991: The Haskell 1.1 report is published. No monads.
1992: The Haskell 1.2 report is published. No monads.
1996: The Haskell 1.3 report is published. Monadic I/O is introduced.
Monadic I/O has been in use in the community first. (?!)
Haskell 1.3, reflecting such community status, completely abolished the
conventional [Response] -> [Request] I/O and introduced monadic I/O
and the do syntax.
26 / 42
The term "monadic I/O" or "IO monad" was originally made to distinguish the new
concept from the old I/O. The term became a new jargon, and the tragedy began.
27 / 42
Downfall
Haskell's I/O can be done without monads, and without knowing monads.
You can remove the type class Monad from Haskell and still do the I/O.
Because monad is no more than interface. You only need the >>= function (and
optionally the do notation) redefined I/O only.
You can remove the type class itself and still do the I/O. Because type class is no
more than interface.
But we call them "IO monad" and people immediately look up "monad" first.
If we called them IO type, this step could have been completely skipped.
The community is encouraging the yak shaving, or a "sidequest."
28 / 42
"To use Haskell one must understand
monad"
29 / 42
JavaScript
>>> ['10', '10', '10'].map(parseInt)
30 / 42
JavaScript
>>> ['10', '10', '10'].map(parseInt)
[10, NaN, 2]
30 / 42
JavaScript
>>> ['10', '10', '10'].map(parseInt)
[10, NaN, 2]
Just as you don't need to know JavaScript to use JavaScript
You don't need to understand monad to use Haskell
30 / 42
All code of do notation is translated
into monad.
Doesn't that mean monad is a required
concept?
31 / 42
All code of do notation is translated
into monad.
Doesn't that mean monad is a required
concept?
Sounds convincing at a glance...
31 / 42
All C/C++/D/Rust/Go code is
translated to Assembly.
Therefore, to learn C/C++/D/Rust/Go,
One must learn Assembly first.
32 / 42
All C/C++/D/Rust/Go code is
translated to Assembly.
Therefore, to learn C/C++/D/Rust/Go,
One must learn Assembly first.
... But now you see the problem.
32 / 42
Counting
(Source: Why I won't be writing a monad tutorial by scottw.)
33 / 42
What is fruit?
When you're trying to explain "What is fruit?" to someone who doesn't know what
fruit is:
Apple is fruit. Orange is fruit. Pear is fruit.
...
Fruit is the seed-bearing structure in angiosperms formed from the ovary after
flowering, normally as a means of botanical reproduction, often edible and juicy with
the sweet or sour taste.
You don't do this.
It is a common intuitive pedagogy to derive abstract concepts from concrete
examples.
34 / 42
Even if you do understand...
Understanding the concept called monad, and actually using monadic types (IO, ST,
[], Maybe, ...) are a completely different matter.
Monad in category theory and monad in Haskell are, again, different.
35 / 42
Even if you do understand...
Understanding the concept called monad, and actually using monadic types (IO, ST,
[], Maybe, ...) are a completely different matter.
Monad in category theory and monad in Haskell are, again, different.
Attempting to learn how to use monads by understanding what they are is
like asking "What is a musical instrument?" and then assuming once you
know the answer to that, you'll be able to play all of the musical instruments.
~kqr, The "What Are Monads?" Fallacy (2015)
35 / 42
So this is what happens
36 / 42
So this is what happens
Beginners believe they must understand monad.
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't.
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
They continue to struggle to understand monad while writing codes in Haskell
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
They continue to struggle to understand monad while writing codes in Haskell
At some point they do understand what monad is
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
They continue to struggle to understand monad while writing codes in Haskell
At some point they do understand what monad is
Then everything feels easy
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
They continue to struggle to understand monad while writing codes in Haskell
At some point they do understand what monad is
Then everything feels easy
They ought to spread this Awakening widely and redeem the people
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
They continue to struggle to understand monad while writing codes in Haskell
At some point they do understand what monad is
Then everything feels easy
They ought to spread this Awakening widely and redeem the people
Another monad tutorial emerges
36 / 42
So this is what happens
Beginners believe they must understand monad.
They can't. (Most people drop out here)
They continue to struggle to understand monad while writing codes in Haskell
At some point they do understand what monad is
Then everything feels easy
They ought to spread this Awakening widely and redeem the people
Another monad tutorial emerges (there can never be enough)
36 / 42
Monad tutorials
37 / 42
Monad tutorials
A 'newbie', in Haskell, is someone who hasn't yet implemented a compiler.
They've only written a monad tutorial.
Pseudonym
37 / 42
Monad tutorials
A 'newbie', in Haskell, is someone who hasn't yet implemented a compiler.
They've only written a monad tutorial.
Pseudonym
Tutorial on how to write a monad tutorial
tora, My how to give a 'monad tutorial' tutorial (2010)
Travis Hance, Write you a monad tutorial (2014)
37 / 42
Monad is
Monad is a type class.
A type class is a set of types.
A type is a set of values.
In Haskell, monad is a shared interface to multiple types that share something in
common.
Therefore, even when a type is monadic, they may look totally unrelated to other
monadic types.
38 / 42
Therefore, to learn monad
39 / 42
Therefore, to learn monad
First use IO type.
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
and List type as well.
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
and List type as well.
Write enough Haskell code. (>1k lines?)
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
and List type as well.
Write enough Haskell code. (>1k lines?)
Then all of a sudden you realize what they have in common. (Aha moment)
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
and List type as well.
Write enough Haskell code. (>1k lines?)
Then all of a sudden you realize what they have in common. (Aha moment)
It doesn't matter you still don't get it. Keep on.
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
and List type as well.
Write enough Haskell code. (>1k lines?)
Then all of a sudden you realize what they have in common. (Aha moment)
It doesn't matter you still don't get it. Keep on.
Never attempt to consciously learn what monad is.
39 / 42
Therefore, to learn monad
First use IO type.
and Maybe type.
and List type as well.
Write enough Haskell code. (>1k lines?)
Then all of a sudden you realize what they have in common. (Aha moment)
It doesn't matter you still don't get it. Keep on.
Never attempt to consciously learn what monad is. It would only lead to frustration
and confusion.
39 / 42
"Well, I did try Haskell, but that monad
thing..."
40 / 42
No! 😄
Don't let monad stop your adventure into Haskell!
41 / 42
Thank you.
42 / 42

More Related Content

More from LINE Corporation

The Magic of LINE 購物 Testing
The Magic of LINE 購物 TestingThe Magic of LINE 購物 Testing
The Magic of LINE 購物 Testing
LINE Corporation
 
GA Test Automation
GA Test AutomationGA Test Automation
GA Test Automation
LINE Corporation
 
UI Automation Test with JUnit5
UI Automation Test with JUnit5UI Automation Test with JUnit5
UI Automation Test with JUnit5
LINE Corporation
 
Feature Detection for UI Testing
Feature Detection for UI TestingFeature Detection for UI Testing
Feature Detection for UI Testing
LINE Corporation
 
LINE 新星計劃介紹與新創團隊分享
LINE 新星計劃介紹與新創團隊分享LINE 新星計劃介紹與新創團隊分享
LINE 新星計劃介紹與新創團隊分享
LINE Corporation
 
​LINE 技術合作夥伴與應用分享
​LINE 技術合作夥伴與應用分享​LINE 技術合作夥伴與應用分享
​LINE 技術合作夥伴與應用分享
LINE Corporation
 
LINE 開發者社群經營與技術推廣
LINE 開發者社群經營與技術推廣LINE 開發者社群經營與技術推廣
LINE 開發者社群經營與技術推廣
LINE Corporation
 
日本開發者大會短講分享
日本開發者大會短講分享日本開發者大會短講分享
日本開發者大會短講分享
LINE Corporation
 
LINE Chatbot - 活動報名報到設計分享
LINE Chatbot - 活動報名報到設計分享LINE Chatbot - 活動報名報到設計分享
LINE Chatbot - 活動報名報到設計分享
LINE Corporation
 
在 LINE 私有雲中使用 Managed Kubernetes
在 LINE 私有雲中使用 Managed Kubernetes在 LINE 私有雲中使用 Managed Kubernetes
在 LINE 私有雲中使用 Managed Kubernetes
LINE Corporation
 
LINE TODAY高效率的敏捷測試開發技巧
LINE TODAY高效率的敏捷測試開發技巧LINE TODAY高效率的敏捷測試開發技巧
LINE TODAY高效率的敏捷測試開發技巧
LINE Corporation
 
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE Corporation
 
LINE Things - LINE IoT平台新技術分享
LINE Things - LINE IoT平台新技術分享LINE Things - LINE IoT平台新技術分享
LINE Things - LINE IoT平台新技術分享
LINE Corporation
 
LINE Pay - 一卡通支付新體驗
LINE Pay - 一卡通支付新體驗LINE Pay - 一卡通支付新體驗
LINE Pay - 一卡通支付新體驗
LINE Corporation
 
LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Platform API Update - 打造一個更好的Chatbot服務LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Corporation
 
Keynote - ​LINE 的技術策略佈局與跨國產品開發
Keynote - ​LINE 的技術策略佈局與跨國產品開發Keynote - ​LINE 的技術策略佈局與跨國產品開發
Keynote - ​LINE 的技術策略佈局與跨國產品開發
LINE Corporation
 
LINE Ads Platformの開発を支えるKafka
LINE Ads Platformの開発を支えるKafkaLINE Ads Platformの開発を支えるKafka
LINE Ads Platformの開発を支えるKafka
LINE Corporation
 
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したかI/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
LINE Corporation
 
生粋のKotlin LoverによるLINEのKotlinの話
生粋のKotlin LoverによるLINEのKotlinの話生粋のKotlin LoverによるLINEのKotlinの話
生粋のKotlin LoverによるLINEのKotlinの話
LINE Corporation
 
LINEで広告プラットフォームをJava+Golangで立ち上げた話
LINEで広告プラットフォームをJava+Golangで立ち上げた話LINEで広告プラットフォームをJava+Golangで立ち上げた話
LINEで広告プラットフォームをJava+Golangで立ち上げた話
LINE Corporation
 

More from LINE Corporation (20)

The Magic of LINE 購物 Testing
The Magic of LINE 購物 TestingThe Magic of LINE 購物 Testing
The Magic of LINE 購物 Testing
 
GA Test Automation
GA Test AutomationGA Test Automation
GA Test Automation
 
UI Automation Test with JUnit5
UI Automation Test with JUnit5UI Automation Test with JUnit5
UI Automation Test with JUnit5
 
Feature Detection for UI Testing
Feature Detection for UI TestingFeature Detection for UI Testing
Feature Detection for UI Testing
 
LINE 新星計劃介紹與新創團隊分享
LINE 新星計劃介紹與新創團隊分享LINE 新星計劃介紹與新創團隊分享
LINE 新星計劃介紹與新創團隊分享
 
​LINE 技術合作夥伴與應用分享
​LINE 技術合作夥伴與應用分享​LINE 技術合作夥伴與應用分享
​LINE 技術合作夥伴與應用分享
 
LINE 開發者社群經營與技術推廣
LINE 開發者社群經營與技術推廣LINE 開發者社群經營與技術推廣
LINE 開發者社群經營與技術推廣
 
日本開發者大會短講分享
日本開發者大會短講分享日本開發者大會短講分享
日本開發者大會短講分享
 
LINE Chatbot - 活動報名報到設計分享
LINE Chatbot - 活動報名報到設計分享LINE Chatbot - 活動報名報到設計分享
LINE Chatbot - 活動報名報到設計分享
 
在 LINE 私有雲中使用 Managed Kubernetes
在 LINE 私有雲中使用 Managed Kubernetes在 LINE 私有雲中使用 Managed Kubernetes
在 LINE 私有雲中使用 Managed Kubernetes
 
LINE TODAY高效率的敏捷測試開發技巧
LINE TODAY高效率的敏捷測試開發技巧LINE TODAY高效率的敏捷測試開發技巧
LINE TODAY高效率的敏捷測試開發技巧
 
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
LINE 區塊鏈平台及代幣經濟 - LINK Chain及LINK介紹
 
LINE Things - LINE IoT平台新技術分享
LINE Things - LINE IoT平台新技術分享LINE Things - LINE IoT平台新技術分享
LINE Things - LINE IoT平台新技術分享
 
LINE Pay - 一卡通支付新體驗
LINE Pay - 一卡通支付新體驗LINE Pay - 一卡通支付新體驗
LINE Pay - 一卡通支付新體驗
 
LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Platform API Update - 打造一個更好的Chatbot服務LINE Platform API Update - 打造一個更好的Chatbot服務
LINE Platform API Update - 打造一個更好的Chatbot服務
 
Keynote - ​LINE 的技術策略佈局與跨國產品開發
Keynote - ​LINE 的技術策略佈局與跨國產品開發Keynote - ​LINE 的技術策略佈局與跨國產品開發
Keynote - ​LINE 的技術策略佈局與跨國產品開發
 
LINE Ads Platformの開発を支えるKafka
LINE Ads Platformの開発を支えるKafkaLINE Ads Platformの開発を支えるKafka
LINE Ads Platformの開発を支えるKafka
 
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したかI/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
I/O intensiveなKafka ConsumerアプリケーションのスループットをLINE Ads Platformではどのように改善したか
 
生粋のKotlin LoverによるLINEのKotlinの話
生粋のKotlin LoverによるLINEのKotlinの話生粋のKotlin LoverによるLINEのKotlinの話
生粋のKotlin LoverによるLINEのKotlinの話
 
LINEで広告プラットフォームをJava+Golangで立ち上げた話
LINEで広告プラットフォームをJava+Golangで立ち上げた話LINEで広告プラットフォームをJava+Golangで立ち上げた話
LINEで広告プラットフォームをJava+Golangで立ち上げた話
 

Recently uploaded

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 

Recently uploaded (20)

Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 

The monad fear

  • 1. LINE Haskell Boot Camp The Monad Fear The Shibuya Camp Finale 1 / 42
  • 2. This slide is the presentation material used in the LINE Haskell Boot Camp that took place in Shibuya, Tokyo, on October 28th, 2016. The latest version of this slide is available at: https://e.xtendo.org/monad 2 / 42
  • 3. Fear, Uncertainty, and Doubt Haskell is difficult to learn Monad is difficult, and therefore Haskell is difficult You need to understand monad in order to use Haskell You need to understand monad in order to use practical Haskell Haskell is a mathematical language Anyways you should learn monad 3 / 42
  • 4. Fear, Uncertainty, and Doubt Haskell is difficult to learn Monad is difficult, and therefore Haskell is difficult You need to understand monad in order to use Haskell You need to understand monad in order to use practical Haskell Haskell is a mathematical language Anyways you should learn monad None of the above is true. 3 / 42
  • 5. Not my original idea. Dan Piponi, The IO Monad for People who Simply Don't Care (2007) Brent Yorgey, Abstraction, intuition, and the “monad tutorial fallacy” (2009) tora, My how to give a 'monad tutorial' tutorial (2010) scottw, Why I won't be writing a monad tutorial (2013) Travis Hance, Write you a monad tutorial (2014) ~kqr, The "What Are Monads?" Fallacy (2015) Justin Le, IO Monad Considered Harmful (2015) The community began to recognize the problem: "Why do so many beginning Haskellers ask the same (wrong) question and go through the same (unnecessary) difficulties?" 4 / 42
  • 6. I've been organizing the South Korean Haskellers' group for nearly a year The two most frequently asked question from the newcomers: 5 / 42
  • 7. 1. If Haskell is so great, why's nobody using it? 6 / 42
  • 8. 2. What the hell is monad? 7 / 42
  • 9. Pedagogical catastrophe Ask the Internet, "What is Haskell?" Purely functional Lazy Uses monads Type classes etc. 8 / 42
  • 10. Pedagogical catastrophe Ask the Internet, "What is Haskell?" Purely functional Lazy Uses monads Type classes etc. In short, things that newcomers can't possibly have a clue of. 8 / 42
  • 11. Pedagogical catastrophe Ask the Internet, "What is Haskell?" Purely functional Lazy Uses monads Type classes etc. In short, things that newcomers can't possibly have a clue of. Using things you don't know in order to teach you something you don't know 8 / 42
  • 12. Pedagogical catastrophe Ask the Internet, "What is Haskell?" Purely functional Lazy Uses monads Type classes etc. In short, things that newcomers can't possibly have a clue of. Using things you don't know in order to teach you something you don't know ?! 8 / 42
  • 13. Pedagogical catastrophe Ask the Internet, "What is Haskell?" Purely functional Lazy Uses monads Type classes etc. In short, things that newcomers can't possibly have a clue of. Using things you don't know in order to teach you something you don't know ?! It would be a miracle if there's no massive frustration. 8 / 42
  • 14. Why was Haskell created? 9 / 42
  • 15. Haskell 2010 Report Preface [...] Goals 1. It should be suitable for teaching, research, and applications, including building large systems. 10 / 42
  • 16. Haskell 2010 Report Preface [...] Goals 1. It should be suitable for teaching, research, and applications, including building large systems. Explicitly stated goal of usefulness in application development. 10 / 42
  • 17. How the Haskell Committee happened 11 / 42
  • 18. How the Haskell Committee happened It is 1987. Non-strict purely functional languages are flooding. 11 / 42
  • 19. How the Haskell Committee happened It is 1987. Non-strict purely functional languages are flooding. Too many choices, redundant independent efforts. None is chosen in the market. 11 / 42
  • 20. How the Haskell Committee happened It is 1987. Non-strict purely functional languages are flooding. Too many choices, redundant independent efforts. None is chosen in the market. Purely functional seems to be a good idea, and it's a pity it's not used. Let's unite and create a language that gets chosen. 11 / 42
  • 21. How the Haskell Committee happened It is 1987. Non-strict purely functional languages are flooding. Too many choices, redundant independent efforts. None is chosen in the market. Purely functional seems to be a good idea, and it's a pity it's not used. Let's unite and create a language that gets chosen. In other words, Haskell was not meant to be academia-only. 11 / 42
  • 22. How the Haskell Committee happened It is 1987. Non-strict purely functional languages are flooding. Too many choices, redundant independent efforts. None is chosen in the market. Purely functional seems to be a good idea, and it's a pity it's not used. Let's unite and create a language that gets chosen. In other words, Haskell was not meant to be academia-only. It was designed to be used in real-life. 11 / 42
  • 23. Haskell: A practical tool that solves real-world problems A web server with higher performance that the ones written in C Standard Chartered: "real time pricing, risk management, data analysis, regulatory systems, desktop and web GUIs, web services, algo pricing, end-user scripting" Facebook's data access tools and antispam tools Haskell in finances: ABN AMRO, Bank of America, Barclays, Credit Suisse, Deutsche Bank, Tsuru Capital 12 / 42
  • 24. FUD Haskell's I/O is somehow special/weird/difficult 13 / 42
  • 25. Haskell main = do putStrLn "Hello. What is your name?" x <- getLine putStrLn ("The input was " ++ x) 14 / 42
  • 26. Python if __name__ == '__main__': print ('Hello. What is your name?') x = input() print ('The input was ' + x) 15 / 42
  • 27. Do the I/O in Haskell. It works. There is NOTHING special about Haskell's I/O. Do it as you did in other (imperative) languages. Deliberately imperative “look and feel” Simon Peyton Jones, Wearing the hair shirt: a retrospective on Haskell (2003) We intentionally made it usable imperatively. The misconception that Haskell's I/O is difficult/special/weird does NOT come from people who actually tried it. One phrase caused all tragedy: 16 / 42
  • 29. IO Monad Considered Harmful Justin Le: The phrase “IO monad” considered harmful. Please do not use it. ... I’m going to say that this is probably the single most harmful and damaging thing in Haskell ... 18 / 42
  • 30. IO Monad Considered Harmful Justin Le: The phrase “IO monad” considered harmful. Please do not use it. ... I’m going to say that this is probably the single most harmful and damaging thing in Haskell ... ?! 18 / 42
  • 31. Unix commands echo STRING cat FILENAME rm FILENAME mkdir DIRNAME echo and cat are commands, STRING and FILENAME are strings, which are argument for commands. command and string are different types. 19 / 42
  • 32. Unix pipe find . | grep ".txt$" tail -f app.log | grep "^system:" > output.txt You want to feed the result output of one command as an input to another command. 20 / 42
  • 33. Haskell's command: action putStrLn :: String -> IO () readFile :: FilePath -> IO String main = do x <- readFile "myname.txt" putStrLn ("Hello, " ++ x ++ "!") Just as echo is a command that takes one string as its argument, putStrLn is an action that takes one String. Just as cat takes a file path as its argument and prints its content, readFile is an action that takes a FilePath and returns its content as a String. Actions and Strings are different types. Actions and the ++ operator are also different types. 21 / 42
  • 34. Haskell's pipe Haskell's pipe looks like this: >>= main = readFile "myname.txt" >>= putStrLn Feed the output of one command as an input of another command. 22 / 42
  • 35. Haskell distinguishes pure functions and actions by their types -- pure function not :: Bool -> Bool (++) :: [a] -> [a] -> [a] -- IO action getLine :: IO String putStrLn :: String -> IO () readFile :: FilePath -> IO String 23 / 42
  • 36. Action is easy. Then why? Just call them "IO action" or "IO type", and explain they are similar to Unix commands, and there will be nothing more to teach. But we call them IO monads and cause this chaos. Bewildering number of beginners are asking "what is monad?" first. (Because when programmers see a strange jargon, they just have to understand it. It's their instinct) "How do I deal with a sequence of multiple numbers in Haskell?" "Use List." or "Use the List type." No one replies with "Use the List monad" unless they're pure evil! Therefore the answer to "How do I do the input/output in Haskell" should also be: "Use the IO type." 24 / 42
  • 37. Our biggest mistake: Using the scary term “monad” rather than “warm fuzzy thing” -- Simon Peyton Jones, Wearing the hair shirt: a retrospective on Haskell (2003) 25 / 42
  • 38. Historical background Since when did Haskell have monads? 26 / 42
  • 39. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. 26 / 42
  • 40. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 26 / 42
  • 41. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. 26 / 42
  • 42. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 26 / 42
  • 43. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. 26 / 42
  • 44. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. No monads. 26 / 42
  • 45. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. No monads. 1992: The Haskell 1.2 report is published. 26 / 42
  • 46. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. No monads. 1992: The Haskell 1.2 report is published. No monads. 26 / 42
  • 47. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. No monads. 1992: The Haskell 1.2 report is published. No monads. 1996: The Haskell 1.3 report is published. 26 / 42
  • 48. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. No monads. 1992: The Haskell 1.2 report is published. No monads. 1996: The Haskell 1.3 report is published. Monadic I/O is introduced. 26 / 42
  • 49. Historical background Since when did Haskell have monads? 1987: The Committee is formed. They chose Miranda as the basis. No monads. 1990: The Haskell 1.0 report is published. No monads. 1991: The Haskell 1.1 report is published. No monads. 1992: The Haskell 1.2 report is published. No monads. 1996: The Haskell 1.3 report is published. Monadic I/O is introduced. Monadic I/O has been in use in the community first. (?!) Haskell 1.3, reflecting such community status, completely abolished the conventional [Response] -> [Request] I/O and introduced monadic I/O and the do syntax. 26 / 42
  • 50. The term "monadic I/O" or "IO monad" was originally made to distinguish the new concept from the old I/O. The term became a new jargon, and the tragedy began. 27 / 42
  • 51. Downfall Haskell's I/O can be done without monads, and without knowing monads. You can remove the type class Monad from Haskell and still do the I/O. Because monad is no more than interface. You only need the >>= function (and optionally the do notation) redefined I/O only. You can remove the type class itself and still do the I/O. Because type class is no more than interface. But we call them "IO monad" and people immediately look up "monad" first. If we called them IO type, this step could have been completely skipped. The community is encouraging the yak shaving, or a "sidequest." 28 / 42
  • 52. "To use Haskell one must understand monad" 29 / 42
  • 53. JavaScript >>> ['10', '10', '10'].map(parseInt) 30 / 42
  • 54. JavaScript >>> ['10', '10', '10'].map(parseInt) [10, NaN, 2] 30 / 42
  • 55. JavaScript >>> ['10', '10', '10'].map(parseInt) [10, NaN, 2] Just as you don't need to know JavaScript to use JavaScript You don't need to understand monad to use Haskell 30 / 42
  • 56. All code of do notation is translated into monad. Doesn't that mean monad is a required concept? 31 / 42
  • 57. All code of do notation is translated into monad. Doesn't that mean monad is a required concept? Sounds convincing at a glance... 31 / 42
  • 58. All C/C++/D/Rust/Go code is translated to Assembly. Therefore, to learn C/C++/D/Rust/Go, One must learn Assembly first. 32 / 42
  • 59. All C/C++/D/Rust/Go code is translated to Assembly. Therefore, to learn C/C++/D/Rust/Go, One must learn Assembly first. ... But now you see the problem. 32 / 42
  • 60. Counting (Source: Why I won't be writing a monad tutorial by scottw.) 33 / 42
  • 61. What is fruit? When you're trying to explain "What is fruit?" to someone who doesn't know what fruit is: Apple is fruit. Orange is fruit. Pear is fruit. ... Fruit is the seed-bearing structure in angiosperms formed from the ovary after flowering, normally as a means of botanical reproduction, often edible and juicy with the sweet or sour taste. You don't do this. It is a common intuitive pedagogy to derive abstract concepts from concrete examples. 34 / 42
  • 62. Even if you do understand... Understanding the concept called monad, and actually using monadic types (IO, ST, [], Maybe, ...) are a completely different matter. Monad in category theory and monad in Haskell are, again, different. 35 / 42
  • 63. Even if you do understand... Understanding the concept called monad, and actually using monadic types (IO, ST, [], Maybe, ...) are a completely different matter. Monad in category theory and monad in Haskell are, again, different. Attempting to learn how to use monads by understanding what they are is like asking "What is a musical instrument?" and then assuming once you know the answer to that, you'll be able to play all of the musical instruments. ~kqr, The "What Are Monads?" Fallacy (2015) 35 / 42
  • 64. So this is what happens 36 / 42
  • 65. So this is what happens Beginners believe they must understand monad. 36 / 42
  • 66. So this is what happens Beginners believe they must understand monad. They can't. 36 / 42
  • 67. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) 36 / 42
  • 68. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) They continue to struggle to understand monad while writing codes in Haskell 36 / 42
  • 69. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) They continue to struggle to understand monad while writing codes in Haskell At some point they do understand what monad is 36 / 42
  • 70. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) They continue to struggle to understand monad while writing codes in Haskell At some point they do understand what monad is Then everything feels easy 36 / 42
  • 71. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) They continue to struggle to understand monad while writing codes in Haskell At some point they do understand what monad is Then everything feels easy They ought to spread this Awakening widely and redeem the people 36 / 42
  • 72. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) They continue to struggle to understand monad while writing codes in Haskell At some point they do understand what monad is Then everything feels easy They ought to spread this Awakening widely and redeem the people Another monad tutorial emerges 36 / 42
  • 73. So this is what happens Beginners believe they must understand monad. They can't. (Most people drop out here) They continue to struggle to understand monad while writing codes in Haskell At some point they do understand what monad is Then everything feels easy They ought to spread this Awakening widely and redeem the people Another monad tutorial emerges (there can never be enough) 36 / 42
  • 75. Monad tutorials A 'newbie', in Haskell, is someone who hasn't yet implemented a compiler. They've only written a monad tutorial. Pseudonym 37 / 42
  • 76. Monad tutorials A 'newbie', in Haskell, is someone who hasn't yet implemented a compiler. They've only written a monad tutorial. Pseudonym Tutorial on how to write a monad tutorial tora, My how to give a 'monad tutorial' tutorial (2010) Travis Hance, Write you a monad tutorial (2014) 37 / 42
  • 77. Monad is Monad is a type class. A type class is a set of types. A type is a set of values. In Haskell, monad is a shared interface to multiple types that share something in common. Therefore, even when a type is monadic, they may look totally unrelated to other monadic types. 38 / 42
  • 78. Therefore, to learn monad 39 / 42
  • 79. Therefore, to learn monad First use IO type. 39 / 42
  • 80. Therefore, to learn monad First use IO type. and Maybe type. 39 / 42
  • 81. Therefore, to learn monad First use IO type. and Maybe type. and List type as well. 39 / 42
  • 82. Therefore, to learn monad First use IO type. and Maybe type. and List type as well. Write enough Haskell code. (>1k lines?) 39 / 42
  • 83. Therefore, to learn monad First use IO type. and Maybe type. and List type as well. Write enough Haskell code. (>1k lines?) Then all of a sudden you realize what they have in common. (Aha moment) 39 / 42
  • 84. Therefore, to learn monad First use IO type. and Maybe type. and List type as well. Write enough Haskell code. (>1k lines?) Then all of a sudden you realize what they have in common. (Aha moment) It doesn't matter you still don't get it. Keep on. 39 / 42
  • 85. Therefore, to learn monad First use IO type. and Maybe type. and List type as well. Write enough Haskell code. (>1k lines?) Then all of a sudden you realize what they have in common. (Aha moment) It doesn't matter you still don't get it. Keep on. Never attempt to consciously learn what monad is. 39 / 42
  • 86. Therefore, to learn monad First use IO type. and Maybe type. and List type as well. Write enough Haskell code. (>1k lines?) Then all of a sudden you realize what they have in common. (Aha moment) It doesn't matter you still don't get it. Keep on. Never attempt to consciously learn what monad is. It would only lead to frustration and confusion. 39 / 42
  • 87. "Well, I did try Haskell, but that monad thing..." 40 / 42
  • 88. No! 😄 Don't let monad stop your adventure into Haskell! 41 / 42