Live data from Hacker News

Monad Tutorials Timeline

wiki.haskell.org

31–40 of 63 posts

Re: Monad Tutorials Timeline

#31
post #14
post #7

I understood the monad concept for a few months in university. After the exam was over, I soon stopped understanding it. The same thing happened with the concept of VC dimension. It's kind of interesting, because we usually don't think of "understanding" as something that comes with a time limit.

It happens all the time. For a brief period I understood musical notation and rhythm and then it was gone. Similarly I had a time in my life where I knew by feeling whether a French noun was le or la.

The sneaky thing here is that understanding, and knowledge in general, disappear silently. So you don't notice it when you unlearn and forget something. Only if a situation comes up where you need that understanding again do you notice that it is gone. Coming to understand something is conscious, losing that understanding is unconscious.

Re: Monad Tutorials Timeline

#33
post #15
post #6

To explain like two fundamental rules (we can make wrapper types, and do flatmap) I will: - Write 5 paragraphs setting up an imaginary scenario involving fantasy elements of aliens, dragons, and a magical kindom where they speak using message boxes - Introduce basic category theory by starting with what a functor is - Explain all the effects of a monad in such general terms that it basically amounts to anything and e…

I've read more than my fair share of these tutorials, and I'd like to be proven wrong here but I don't think I've ever seen one that explains what the point of these functional constructs (similarly with Applicative etc.) is. "You can do IO now." So what? I could do IO before that as well. Very rarely are practical explanations discussed. Even if they are discussed, the treatment is shallow and useless.

Nobody will explain you like this, but the main point was being able to satisfy the compiler without introducing an escape hatch into the language.

Haskell is based on Miranda, and Miranda is based on Hope. Purely functional languages were really purely functional, academic experiments with no way to express side effects, so no way to express practical programs.

Philip Wadler took the monad (the name that already existed in category theory), and showed how computations could be expressed in Haskell with the “do notation” as an example. That made Haskell practical without breaking the “beauty” of the language, by having to introduce new special syntax or something outside the type checker capacity.

So, I don’t think there’s a motivation besides being an exercise in expressivity within the limitations of pure functional programming. Similar ideas in describing computation as lazy executed instructions already existed elsewhere, like the interpreter pattern.

Re: Monad Tutorials Timeline

#34
It took me a long time to write an explainer on embeddings, and one day I will finally finish my Monad tutorial. I think fundamentally you need to have needed them to solve a problem to get them, and outside of pure languages you have to do a lot of special-condition setup to explain why you need them. "You Could Have Invented Monads"[0] is probably my favourite existing one.

0: https://blog.sigfpe.com/2006/08/you-could-have-invented-mona...

Re: Monad Tutorials Timeline

#36
post #15
post #6

To explain like two fundamental rules (we can make wrapper types, and do flatmap) I will: - Write 5 paragraphs setting up an imaginary scenario involving fantasy elements of aliens, dragons, and a magical kindom where they speak using message boxes - Introduce basic category theory by starting with what a functor is - Explain all the effects of a monad in such general terms that it basically amounts to anything and e…

I've read more than my fair share of these tutorials, and I'd like to be proven wrong here but I don't think I've ever seen one that explains what the point of these functional constructs (similarly with Applicative etc.) is. "You can do IO now." So what? I could do IO before that as well. Very rarely are practical explanations discussed. Even if they are discussed, the treatment is shallow and useless.

* Composition and reasoning. Standard things in FP. Build big things from little pieces. Understand them the same way.

* Explicitly define the order of evaluation (important in Haskell, where lazy evaluation makes the default order of evaluation difficult to trace)

* Useful mental model that helps with 1) design and 2) understanding new concepts

* Abstraction. Ignore irrelevant details. Write the standard library once, use it in many different situations.

Re: Monad Tutorials Timeline

#37
post #28
post #15

Earlier quoted context omitted.

I've read more than my fair share of these tutorials, and I'd like to be proven wrong here but I don't think I've ever seen one that explains what the point of these functional constructs (similarly with Applicative etc.) is. "You can do IO now." So what? I could do IO before that as well. Very rarely are practical explanations discussed. Even if they are discussed, the treatment is shallow and useless.

You may appreciate my own contribution, https://www.jerf.org/iri/post/2958/ , which includes an entire section titled "If They're So Wonderful Why Aren't They In My Favorite Language?", a section explaining why IO is not a good lens to understand monads and why "monads" don't really have anything to do with "making IO possible" ( very common misconception), as well as what I believe to be one of the more practical ap…

I read this years ago and I think it's the best one I've read. Thanks for writing it!

Re: Monad Tutorials Timeline

#38
post #33
post #15

Earlier quoted context omitted.

I've read more than my fair share of these tutorials, and I'd like to be proven wrong here but I don't think I've ever seen one that explains what the point of these functional constructs (similarly with Applicative etc.) is. "You can do IO now." So what? I could do IO before that as well. Very rarely are practical explanations discussed. Even if they are discussed, the treatment is shallow and useless.

Nobody will explain you like this, but the main point was being able to satisfy the compiler without introducing an escape hatch into the language. Haskell is based on Miranda, and Miranda is based on Hope. Purely functional languages were really purely functional, academic experiments with no way to express side effects, so no way to express practical programs. Philip Wadler took the monad (the name that already exi…

The point is rather that in a pure language, each io operation needs to be dependent on a sort of "world state" which is updated for each operation. They chose to implement this state as the io monad but there could have been other ways.

Re: Monad Tutorials Timeline

#39
Here’s my monad tutorial for programmers

A monad is anything you can flatmap with

The monad of list is you flatmap a list on a list and instead of getting a list of lists, as you would if you just mapped, you get a single flattened list

The monad of Result is you flatmap many function calls (like http requests or whatever) on each other and instead of getting many results, you get a single flattened result

Most of you already know this, without necessarily even knowing what a Monad is

Monad literally just means "one thing" - you take many things, and flatmap them into one

Thanks for attending my ted talk

Post reply on HN