class: title, center, middle LINE Haskell Boot Camp .title[ # The Monad Fear ] _The Shibuya Camp_
Finale --- - This slide deck was the visual aid for [XT](https://xtendo.org)'s presentation in the [LINE Haskell Boot Camp](https://engineering.linecorp.com/en/blog/detail/112) that took place in Shibuya, Tokyo, on October 28th, 2016. - The latest version of the deck is available at:
--- ## 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. --- ## Not my original idea. - Dan Piponi, _[The IO Monad for People who Simply Don't Care](http://blog.sigfpe.com/2007/11/io-monad-for-people-who-simply-dont.html)_ (2007) - Brent Yorgey, _[Abstraction, intuition, and the “monad tutorial fallacy”](https://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/)_ (2009) - tora, _[My how to give a 'monad tutorial' tutorial](http://www.doc.ic.ac.uk/~tora/monadsI.txt)_ (2010) - scottw, _[Why I won't be writing a monad tutorial](http://fsharpforfunandprofit.com/posts/why-i-wont-be-writing-a-monad-tutorial/)_ (2013) - Travis Hance, _[Write you a monad tutorial](https://tjhance.quora.com/Write-you-a-monad-tutorial)_ (2014) - ~kqr, _[The "What Are Monads?" Fallacy](http://two-wrongs.com/the-what-are-monads-fallacy)_ (2015) - Justin Le, _[IO Monad Considered Harmful](http://blog.jle.im/entry/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?" --- ## I've been organizing the South Korean Haskellers' group for nearly a year The two most frequently asked question from the newcomers: --- class: center, middle ## 1. If Haskell is so great, why's nobody using it? --- class: center, middle ## 2. What the hell is monad? --- ## 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. --- class: center, middle ## Why was Haskell created? --- ## 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**. --- ## 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**. --- ## Haskell: A practical tool that solves real-world problems - A web server with higher performance than 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 --- class: center, middle FUD ## Haskell's I/O is
You don't need to understand monad to use Haskell --- class: center ## All code of `do` notation is translated into monad.
Doesn't that mean monad is a required concept? -- Sounds convincing at a glance... --- class: center ## 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. --- ## Counting (Source: [Why I won't be writing a monad tutorial](http://fsharpforfunandprofit.com/posts/why-i-wont-be-writing-a-monad-tutorial/) by scottw.) --- ## 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. --- ## 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](http://two-wrongs.com/the-what-are-monads-fallacy)_ (2015) --- ## 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) --- ## Monad tutorials -- > A 'newbie', in Haskell, is someone who hasn't yet implemented a compiler. They've only written a monad tutorial.
> [Pseudonym](http://sequence.complete.org/hwn/20061122) -- - Tutorial on how to write a monad tutorial - tora, _[My how to give a 'monad tutorial' tutorial](http://www.doc.ic.ac.uk/~tora/monadsI.txt)_ (2010) - Travis Hance, _[Write you a monad tutorial](https://tjhance.quora.com/Write-you-a-monad-tutorial)_ (2014) --- ## 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. --- ## 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. --- class: center, middle ## "Well, I did try Haskell, but that monad thing..." --- class: center, middle ## No!
Don't let monad stop your adventure into Haskell! --- ## Thank you. -
- GitHub: [@xtendo-org](https://github.com/xtendo-org) - Twitter: [@xtendo_org](https://twitter.com/xtendo_org)