Skip to content
0:00 / 0:00

#monads#functors#flatmap

Monad - FunFunFunction #21

Fun Fun Function

257K subscribers • 2 videos on Hallway

YouTube
  • Recommended by 3 people: 3 on Hacker News.
  • A classic. People kept recommending it from 2016 to 2021.
  • Presented by Mattias Petter Johansson, creator of FunFunFunction
  • May be out of date. Uploaded 10 years ago, in an area where tools change fast.

Intermediate. Assumes working knowledge.

127K views10 years ago3 recommendations

Programming languagesWeb developmentJavaScriptFunctional programming

Mattias Petter Johansson explains monads in JavaScript by comparing them to functors and demonstrating how they implement the flatMap method.

💖 Support the show by becoming a Patreon patreon.com/funfunfunction Monads is a type of Functor, so you need to know what a Functor is in order for this episode to make sense. Thankfully, there there is a FunFunFunction episode for that, and you can watch it here: So, what is a monad? Remember that a Functor is an object that implements *map*? Well, a monad is a more powerful functor that also implements *flatMap*. Code from the episode gist.github.com/mpj/ca167aad371c67372f3b Mad props to @drboolean for helping me to understand Monads. Besides following him on Twitter, you should watch his awesome “Classroom Coding with Prof. Frisby Pt1” youtube.com/watch?v=h_tkIpwbsxY&list=PLK_hdtAJ4KqX0JOs_KMAmU… Quick intro to Fetch API sitepoint.com/introduction-to-the-fetch-api/ BaconJS baconjs.github.io/ Google Translate API cloud.google.com/translate/v2/getting_started 💛 Follow on Twitch and support by becoming a Subscriber We record the show live Mondays 7 AM PT twitch.tv/funfunfunction 💛 Fun Fun Forum Private discussion forum with other viewers in between shows. funfunforum.com. Available to patron members, become one at patreon.com/funfunfunction 💛 mpj on Twitter twitter.com/mpjme 💛 CircleCI (Show sponsor) Robust and sleek Docker-based Continuous Integration as a service. I used CircleCI prior to them becoming a sponsor and I love that their free tier is powerful enough for small personal projects, even if they are private. Use this link when you sign up to let them know you came from here: circleci.funfunfunction.com 💛 Quokka (Show sponsor) Wonder how MPJ evaluates JavaScript inline his editor. Quokka is the answer - use this link when you buy to let them know you came from here: quokka.funfunfunction.com 💛 FUN FUN FUNCTION Since 2015, Fun Fun Function (FFF) is one of the longest running weekly YouTube shows on programming 🏅 thanks to its consistency and quality reaching 200,000+ developers. 🤦‍♂️ The Failing Together concept is what makes FFF unique. Most coding content out there focus on step-by-step tutorials. We think tutorials are too far removed from what everyday development is like. Instead, FFF has created a completely new learning environment where we grow from failure, by solving problems while intensively interacting with a live audience. Tutorials try to solve a problem. Failing Together makes you grow as a developer and coworker. 📹 Each show is recorded live on Twitch in a 2-hour livestream on Mondays. The host, assisted by the audience, is tasked to complete a programming challenge by an expert guest. Like in the real world, we often fail, and learn from it. This, of course, reflects what the audience identifies with, and is one of the most praised aspects of the show. ⏯ On Fridays, an edited version of the show is adapted for and published on YouTube. Content Topics revolve around: Jav

Why it's here

3 people recommend this

What people say. Highly recommended by developers as the clearest and most intuitive explanation of monads for programmers transitioning from object-oriented to functional concepts.

k__on Hacker News • Recommends

On “Functors, Applicatives, and Monads in Pictures (2013)”

I read this example years ago, and it didn't clear anything up for me. After half a year of trying to understand monads, I saw a video by MPJ/Funfunfunction 0 and it finally made sense. 0 link to this video

intellectableon Hacker News • Recommends

On “Functional Programming Jargon”

I like how mpj explains it. Monad - FunFunFunction #21 link to this video Furthermore, the creator of Elm has a fun explanation too. Evan Czaplicki - Let's be mainstream! User focused design in Elm - Curry On link More serious computer scientist explains monads in the following. Erik Meijer: Functional Programming link and here too link

icc97on Hacker News • Recommends

On “JavaScript Promises Discussion: Make Them Monadic? (2013)”

Here's a half baked explanation, as in just the flatmap part. map is understood in javascript. So you 'just' need to make the leap to flatmap. Which is mapping something and flattening the result. So still you need to learn is what flatten is. But that's not too hard to learn. Try the funfunfunction video 0 0: link to this video

cosinetauon Hacker News • Mentions

On “Attitudes That Lead to Maintainable Code”

A nomad is something that goes "nom!" ;) A monad is basically an function, in the algebra sense, that will take a set of input, and map it to a different output. That's the most simple definition I can give without getting into the math, and it's been a minute since I've really gotten into Group theory. Maybe through a Haskell tutorial for some hands-on guidance? link link to this video

u/physicalbitcoinin r/Frontend • Mentions

On “The Marvellously Mysterious JavaScript Maybe Monad”

Funfunfunction has a good explanation here: link to this video It might be a little oversimplified, but it gets the point across, and shows some real applications. He uses flatmap, IIRC. Edit: OTOH, Stack Overflow say flatmap isn't a monad. http://stackoverflow.com/questions/27750046/is-a-collection-with-flatmap-a-monad