What is a Monad? - Math vs Computer Science

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 พ.ค. 2024
  • Monads look pretty different in math vs in programming... what exactly are they? (Don't say they're just monoids in the category of endofunctors,... I mean it.)
    ______________
    Timestamps:
    00:00 - Introduction
    00:40 - What is a monad?
    01:48 - What is a monad to a functional programmer?
    03:28 - The state monad
    04:39 - The maybe monad
    05:22 - Recipe for a monad
    06:21 - What is a monad to a category theorist?
    07:21 - The "linear algebra" monad
    08:35 - Monad unit and multiplication
    09:24 - Monad algebras
    10:27 - Reconciling the two notions of a monad
    11:26 - Kleisli category
    11:44 - Eilenberg-Moore category
    12:30 - Monad "bind"
    13:34 - Thx 4 watching
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 173

  • @robertstuckey6407
    @robertstuckey6407 17 วันที่ผ่านมา +121

    I do not know what a monad is or why im here but im glad i am

  • @badabing3391
    @badabing3391 13 วันที่ผ่านมา +105

    5th category, youtube algorithm is trying to get me interested in math.

    • @SheafificationOfG
      @SheafificationOfG  13 วันที่ผ่านมา +27

      Has it worked? Have you converted? It's only a matter of time.
      (Also, this puts you in one of the first two categories: TH-cam is your category theory/functional programming friend)

    • @badabing3391
      @badabing3391 13 วันที่ผ่านมา +8

      @SheafificationOfG ill know in a few months. May or may not be pursuing a math minor rn.

    • @SheafificationOfG
      @SheafificationOfG  13 วันที่ผ่านมา +6

      @@badabing3391 let's goooooooo

    • @badabing3391
      @badabing3391 13 วันที่ผ่านมา +3

      @SheafificationOfG dont get too excited, im still an engineer foremost 😅

  • @phecdaDia
    @phecdaDia 8 วันที่ผ่านมา +15

    Just because I clicked on this video and already knew what a Monad was means I am itching for a fight. I mean I am itching for a fight, but not about Monads.

    • @SheafificationOfG
      @SheafificationOfG  7 วันที่ผ่านมา +3

      I've got my ad hominem ready for whenever you are (whatever the fight is about).

  • @iamtraditi4075
    @iamtraditi4075 13 วันที่ผ่านมา +43

    Dude, this was a banger video. Unironically a great explanation of the state monad too - seeing the parameter list and return type change was EXACTLY what I needed to make this idea click :)

    • @SheafificationOfG
      @SheafificationOfG  13 วันที่ผ่านมา +6

      Glad to hear I could manipulate the state of your understanding (in a good way)!

  • @Canadian_Teemo
    @Canadian_Teemo 3 วันที่ผ่านมา +2

    I don't think I understood work in this video, as a category 5 viewer, youtube recommendation, then I just watched for all the memes. I feel like you need a Master's in mathematics to understand something from this video.

  • @evannixon6402
    @evannixon6402 หลายเดือนก่อน +15

    Fantastic video
    I never realized how important it was to understand why axioms were chosen

  • @cloneguy77
    @cloneguy77 12 วันที่ผ่านมา +9

    I didn’t completely follow, especially nearing the end, but I’m going to rewatch when I’m in a better frame of mind. This is very very good stuff man I always love to see high level math videos on TH-cam that aren’t just 1hr long lectures. Keep up the good work!

  • @eddielam2875
    @eddielam2875 12 วันที่ผ่านมา +6

    An example of this in algebraic geometry: Let Sch be the category of schemes, and CRing^op be the opposite category of commutative rings, then the global section functor Γ admits a right adjoint which is called Spec, which takes a commutative ring to its prime spectrums. As general consequences of pair of adjoint functors the composition Spec(Γ(-)) has the structure of a monad. For a scheme S, there is a canonical affinization map S -> Spec(Γ(S)); and Spec(Γ(Spec(Γ(-))) = Spec(Γ(-)) is always true because Γ(Spec) is (equivalent to) the identity
    by construction of Spec. In this case, an algebra over this monad is nothing but an affine scheme.

    • @SheafificationOfG
      @SheafificationOfG  12 วันที่ผ่านมา +5

      Idempotent monads like this (arising from a fully faithful right adjoint) are an interesting subclass, since the category of algebras is a full subcategory of the original category (whereas you normally expect a category of algebras to be in some sense "bigger" than the original).
      However, this special property makes the "algebra" aspect of monadicity harder to appreciate in this case.
      For example, the category Grp of groups is monadic over sets, and this reflects how groups are a kind of algebraic structure over sets (like my linear algebra example). On the other hand, the category Ab of abelian groups is also monadic over Grp, but since this arises from an idempotent monad, Ab is a full subcategory of Grp, making it weirder to see it as expressing abelian groups as an algebraic structure over groups. Of course, this isn't to say there is no algebraic structure going on here: abelian groups are precisely the groups with an additional compatible group structure (by Eckmann-Hilton).
      Your example is similar in this respect: CRing^op is already the category of affine schemes, and it's kinda strange to view affine schemes as "schemes with some kind of algebraic structure", but you *can* do it.

    • @eddielam2875
      @eddielam2875 12 วันที่ผ่านมา +1

      @@SheafificationOfG Yea there are many examples of idempotent monads arising in algebraic geometry. For example, if X is a variety with ring of functions R, then the adjunction R-mod QCoh(X) given by localization and global sections gives an idempotent monad. This realizes a subcategory of QCoh(X) as R-module, and I believe applying Barr-Beck theorem tells you that this is an equivalence iff X is affine.

    • @birdbeakbeardneck3617
      @birdbeakbeardneck3617 10 วันที่ผ่านมา +1

      me first year in stem, with one abstract algebra course: hmm, impressive, very nice

  • @Max-jc1to
    @Max-jc1to หลายเดือนก่อน +8

    This was the best explanation I heard on Monads, I hope you continue to make videos like this one

  • @abyzdoof8821
    @abyzdoof8821 7 วันที่ผ่านมา +1

    You explained everything super clearly. Even though this is easily the highest level, I've heard anyone go into monads, I actually understood. Can't wait for the next upload!

  • @rudrapednekar1644
    @rudrapednekar1644 8 วันที่ผ่านมา +2

    Great video man!!!
    That SQL injection tho😂😂😂

    • @SheafificationOfG
      @SheafificationOfG  8 วันที่ผ่านมา

      Gotta keep the bots away somehow 😉

  • @johnzhou4877
    @johnzhou4877 8 วันที่ผ่านมา +2

    As an undergraduate interested in categorical logic, I'm so glad that I clicked this video, really well done! Love the concise yet accurate language and the funny presentation style, can't wait to see more videos!
    Also just a curious question: judging from your username, I would assume you have some background in topos theory? If so, how do you make sense of Beck monadicity theorem and Pare theorem (the latter says that for every elementary topos, the "powerobject" functor is monadic)? I never feel comfortable with them.

    • @SheafificationOfG
      @SheafificationOfG  8 วันที่ผ่านมา +1

      Regarding Beck monadicity: if you're willing to accept that a "monad" is a general way of encoding a flavour of "algebraic structure" on objects of a certain category, then Beck's monadicity theorem is a recognition theorem for when you can view objects of one category as "objects of another category with algebraic structure". This perspective also gives a bit of intuition for the conditions on a functor U : C -> D to be monadic:
      1. U having a left adjoint establishes that you can use the putative algebraic structure to *generate* an algebra from an "unstructured" object in D (analogous to "formal linear combinations" generated over a set in the video), and it identifies which objects of C are freely-generated.
      2. U creating coequalisers of U-split pairs reflects the fact that a general algebra admits a presentation via "generators and relations" (like a free resolution of a ring; in fact, this is a good place to draw intuition).
      Regarding Paré's result on the monadicity of the contravariant power-object functor, I think a good starting point for drawing intuition is to look at the category of Sets. Again, if we take "monadicity" of U : C -> D to mean "C is the category of objects of D equipped with a certain kind of algebraic structure", then understanding the monadicity of \Omega : E^op -> E amounts to understanding how to view objects of E^op as objects of E with algebraic structure. For sets, (classically) we have an equivalence of categories between Set^op and the category CABA of "complete atomic Boolean algebras", from which it's apparent what algebraic structure is encoded by the contravariant powerset functor. This gives an impression of what's going on in general (though, you have to let go of LEM, so you don't get "Boolean algebras").

  • @SlowMonoxide
    @SlowMonoxide 8 วันที่ผ่านมา +2

    This is *hilarious* and also a pretty clear and concise explanation, subbed

  • @jaysonbunnell8097
    @jaysonbunnell8097 8 วันที่ผ่านมา +11

    love the video! As a tip for audio quality (because microphones are expensive), it’s a great trick to record the white noise in the room you’re recording in, and put it over any blank spots in the script. That way the audio-to-no-audio transformation isn’t so harsh. Subbed!

    • @SheafificationOfG
      @SheafificationOfG  8 วันที่ผ่านมา +3

      Thanks for the tip! I'll consider it for my next video(s)!

    • @AKW91
      @AKW91 8 วันที่ผ่านมา

      If your recording software supports VST plugins you can install Reaper and use ReaFir in subtract mode to remove the background noise. Just let it build the noise profile for few seconds and it's almost gone on all recordings.

    • @thezipcreator
      @thezipcreator 5 วันที่ผ่านมา

      @@AKW91 audacity has noise removal built-in

  • @stokedfool
    @stokedfool 7 วันที่ผ่านมา +1

    Accessible and satisfying explanation of Monads. Thank you.

  • @ProactiveYellow
    @ProactiveYellow 17 วันที่ผ่านมา +17

    Ok but what if I WANT to assume the axiom of choice?

    • @SheafificationOfG
      @SheafificationOfG  17 วันที่ผ่านมา +20

      Ok well why don't you go CHOOSE a basis for the vector space of continuous functions R -> R 😤

    • @biblebot3947
      @biblebot3947 17 วันที่ผ่านมา +4

      @@SheafificationOfGalready did.

    • @ProactiveYellow
      @ProactiveYellow 17 วันที่ผ่านมา +5

      @@SheafificationOfG sure:
      Let B be one of the bases for the vector space of continuous functions R→R guaranteed by the axiom of choice. By Zorn's lemma we may (through torturous restructuring into any other arbitrary form of the AoC) select basis B. Thus we now have a basis for the aforementioned space. QED.

    • @ThePiotrekpecet
      @ThePiotrekpecet 9 วันที่ผ่านมา +1

      ​@@SheafificationOfGI choose polynomials as a perfectly good Schauder basis 😎

    • @SheafificationOfG
      @SheafificationOfG  9 วันที่ผ่านมา +2

      @@ThePiotrekpecet Hamel basis or gtfo

  • @ke9tv
    @ke9tv 14 วันที่ผ่านมา +4

    I'm in Category IIIa. I know what a monad is, and itching to tell the categorists and functional programmers to please keep the noise down, I'm trying to get some work done here!

  • @Jesin00
    @Jesin00 10 วันที่ผ่านมา +3

    I don't know how many people you expected to actually laugh out loud at the punchline at 1:18, but I *was* one of them.

  • @b1rds_arent_real
    @b1rds_arent_real 10 วันที่ผ่านมา +3

    You deserve those 1m+ subs, keep going!

    • @SheafificationOfG
      @SheafificationOfG  10 วันที่ผ่านมา +2

      Really gunning for that non-free vector space reveal, eh? 😏

  • @Misteribel
    @Misteribel 7 วันที่ผ่านมา

    Good luck with your channel! This is great content. Personally, I'd use less distracting images while on such a denser subject (i know the subject matter, but still had to pause a few times or scroll back).

  • @u03b52
    @u03b52 7 วันที่ผ่านมา +1

    very intuitive explanation 👍

  • @kualta
    @kualta หลายเดือนก่อน +9

    9 subscribers chad lord. make it 10.

    • @SheafificationOfG
      @SheafificationOfG  หลายเดือนก่อน +5

      ⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⠛⠛⠋⠉⠈⠉⠉⠉⠉⠛⠻⢿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣿⡿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⢿⣿⣿⣿⣿
      ⣿⣿⣿⣿⡏⣀⠀⠀⠀⠀⠀⠀⠀⣀⣤⣤⣤⣄⡀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿
      ⣿⣿⣿⢏⣴⣿⣷⠀⠀⠀⠀⠀⢾⣿⣿⣿⣿⣿⣿⡆⠀⠀⠀⠀⠀⠀⠀⠈⣿⣿
      ⣿⣿⣟⣾⣿⡟⠁⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣷⢢⠀⠀⠀⠀⠀⠀⠀⢸⣿
      ⣿⣿⣿⣿⣟⠀⡴⠄⠀⠀⠀⠀⠀⠀⠙⠻⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⣿
      ⣿⣿⣿⠟⠻⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠶⢴⣿⣿⣿⣿⣿⣧⠀⠀⠀⠀⠀⠀⣿
      ⣿⣁⡀⠀⠀⢰⢠⣦⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣿⡄⠀⣴⣶⣿⡄⣿
      ⣿⡋⠀⠀⠀⠎⢸⣿⡆⠀⠀⠀⠀⠀⠀⣴⣿⣿⣿⣿⣿⣿⣿⠗⢘⣿⣟⠛⠿⣼
      ⣿⣿⠋⢀⡌⢰⣿⡿⢿⡀⠀⠀⠀⠀⠀⠙⠿⣿⣿⣿⣿⣿⡇⠀⢸⣿⣿⣧⢀⣼
      ⣿⣿⣷⢻⠄⠘⠛⠋⠛⠃⠀⠀⠀⠀⠀⢿⣧⠈⠉⠙⠛⠋⠀⠀⠀⣿⣿⣿⣿⣿
      ⣿⣿⣧⠀⠈⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠟⠀⠀⠀⠀⢀⢃⠀⠀⢸⣿⣿⣿⣿
      ⣿⣿⡿⠀⠴⢗⣠⣤⣴⡶⠶⠖⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⡸⠀⣿⣿⣿⣿
      ⣿⣿⣿⡀⢠⣾⣿⠏⠀⠠⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠛⠉⠀⣿⣿⣿⣿
      ⣿⣿⣿⣧⠈⢹⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣰⣿⣿⣿⣿
      ⣿⣿⣿⣿⡄⠈⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣴⣾⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣷⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣿⣦⣄⣀⣀⣀⣀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⡄⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀⠀⠀⠙⣿⣿⡟⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠁⠀⠀⠹⣿⠃⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⢐⣿⣿⣿⣿⣿⣿⣿⣿⣿
      ⣿⣿⣿⣿⠿⠛⠉⠉⠁⠀⢻⣿⡇⠀⠀⠀⠀⠀⠀⢀⠈⣿⣿⡿⠉⠛⠛⠛⠉⠉
      ⣿⡿⠋⠁⠀⠀⢀⣀⣠⡴⣸⣿⣇⡄⠀⠀⠀⠀⢀⡿⠄⠙⠛⠀⣀⣠⣤⣤⠄⠀

  • @therealist9052
    @therealist9052 6 วันที่ผ่านมา

    Best math + meme channel on YT. Subbed.

  • @lukiatiyah-singer5100
    @lukiatiyah-singer5100 9 วันที่ผ่านมา +1

    I'm from the 5th category of people who are using jet bundles a lot in their day to day life and therefore need an explanation what a monad is to understand what a co-monad could be.
    But for real, great video, love your style and I feel I finally understood something about monads. Thanks a lot!

    • @mickschilder3633
      @mickschilder3633 8 วันที่ผ่านมา +1

      Okay as a person that knows about monads and jet bundles i do not immediately see what comonads hage to do with jet bundles, or are jet bundles comonads? (Its 00:18 and i have not the brain capacity to figure this out without paper)

  • @endersteph
    @endersteph 15 วันที่ผ่านมา +5

    I've seen a lot of monad-explainers on youtube, but this is the first one I feel I really understood, so thanks for that! What would you recommand to start learning category theory? Or perhaps to learn more about applications of cat in cs?
    (Btw, I AM assuming the axiom of choice, and in fact in every waking moment of my life I am consciously assuming it!)

    • @SheafificationOfG
      @SheafificationOfG  15 วันที่ผ่านมา +4

      Thanks so much, I appreciate it (except for the part where you choose the axiom of choice)!
      As for category theory recommendations: I've heard that "Category Theory for Programmers" (github.com/hmemcpy/milewski-ctfp-pdf) is good, but I've personally never read it.
      I studied category theory purely as a mathematical endeavour, mainly in its intersection with algebraic topology, so I can't say my curated advice would be too valuable to someone on the CS side, though hopefully the book reference is useful.

  • @kotfare1698
    @kotfare1698 6 วันที่ผ่านมา

    this is fantastic, perfect blend of humour and wit

  • @ucantSQ
    @ucantSQ 10 วันที่ผ่านมา +1

    That was masterful. Split your arrow on a double bulls-eye. Subbed.

  • @sillystuff6247
    @sillystuff6247 10 วันที่ผ่านมา +2

    keep doing videos on whatever tickles your fancy.
    you might be onto something.
    your career options are
    wider & higher than previously known.

  • @Kyler1Ace
    @Kyler1Ace หลายเดือนก่อน +8

    Best debut video ive watched with this few views

    • @Kyler1Ace
      @Kyler1Ace หลายเดือนก่อน +4

      Explaining monads in fp as just being a type that allows you to compose an effect when used on any other arbitrary type instantly made perfect sense compared to all the other explanations I've heard over the years when trying to grok it

    • @SheafificationOfG
      @SheafificationOfG  หลายเดือนก่อน +1

      Thanks a tonne, I'm flattered. So happy to hear found the explanation clear!

  • @krupt5995
    @krupt5995 11 วันที่ผ่านมา +3

    0:16 My brother in Christ, I just like math

  • @skynmystical4861
    @skynmystical4861 หลายเดือนก่อน +1

    Amazing. Make more!!

  • @VaviVove
    @VaviVove 12 ชั่วโมงที่ผ่านมา

    I feel like my brain is getting bigger each time I'm watching this video... Bros is it what we call banger content?

  • @sebwys900
    @sebwys900 13 วันที่ผ่านมา +2

    Monads at 3am, life couldn’t be better

  • @macchiato_1881
    @macchiato_1881 7 วันที่ผ่านมา

    Im from the category of people that accidentally clicked a FP video and the algorithm has been sandblasting my face with FP related vids ever since last week

  • @ZapPack
    @ZapPack 5 วันที่ผ่านมา

    monoid monad endofunctor T Algebra formal R3 vector space

  • @pomtubes1205
    @pomtubes1205 9 วันที่ผ่านมา +1

    A monad is a monoid in the category of endofunctors.
    A monad is a monoid in the category of endofunctors.
    A monad is a monoid in the category of endofunctors.
    A monad is a monoid in the category of endofunctors.
    A monad is a monoid in the category of endofunctors.
    A mo

    • @SheafificationOfG
      @SheafificationOfG  9 วันที่ผ่านมา +1

      ....................../´¯/)
      ....................,/¯../
      .................../..../
      ............./´¯/'...'/´¯¯`·¸
      ........../'/.../..../......./¨¯\
      ........('(...´...´.... ¯~/'...')
      .........\.................'...../
      ..........''...\.......... _.·´
      ............\..............(
      ..............\.............\...

    • @pomtubes1205
      @pomtubes1205 9 วันที่ผ่านมา

      @@SheafificationOfG 🤣🤣🤣

  • @thrilhousesf
    @thrilhousesf 7 วันที่ผ่านมา

    Some time last year I decided it would be fun to sit down and understand the 'monoid in the category of endofunctors' definition. It took 3 days on my whiteboard and at the end, it just means a functor with join and pure satisfying the unit and associativity laws, and provides no further insight. I was right though, it was fun.

    • @SheafificationOfG
      @SheafificationOfG  7 วันที่ผ่านมา

      Yep, exactly!
      fmap :: functorial
      join :: multiplication
      ret :: unit
      While "monoid in a category of endofunctors" is really nice for never forgetting the axioms of a monad, it definitely doesn't help with understanding what a monad's all about.

  • @bdfb-th5ek
    @bdfb-th5ek 3 วันที่ผ่านมา

    Geez. I learned both FP+Formalization (under the umbrella term of 'Programming Language') and pure math, and was thinking about all the foundation stuffs from time to time from my enjoyment. You are very strong at explaining the _intuition_ behind it as clear as possible while getting as deep as it can get in understanding. Much thanks and I look forward for future videos!!
    Suggestion that you can freely ignore: Is the set X of 'computable' real numbers countable? There is only a countable number of programs, so it should be countable. Now by enumerating X and using the Cantor diagonalization, can't we get contradiction by finding a computable number outside X? (A counterargument gives a resolution of Halting problem) Now how about the set of 'defineable' real numbers? There is only a countable number of math statements. How about we do the Cantor diagnoalization again here?
    I'm saying all this without clarity and only handwaiving... what I'd like to see is a crystal clear clarification around those issues if you get what I mean.

    • @SheafificationOfG
      @SheafificationOfG  3 วันที่ผ่านมา

      Thanks! The angle on Cantor's diagonalisation to prove that the computable numbers are not computably enumerable (despite being countable) is definitely cute! I'll see if it fits with some topics I might want to cover down the road!

  • @colonelmoustache
    @colonelmoustache 8 วันที่ผ่านมา

    That was quick, that was clean

  • @jrgenolsen3290
    @jrgenolsen3290 13 วันที่ผ่านมา +1

    very good video the sweetspot of math and FP

  • @njdarda
    @njdarda 9 วันที่ผ่านมา

    youtube has been desperate for me to watch this video for weeks so here i finally am. cool stuff.

  • @DemonixTB
    @DemonixTB 6 วันที่ผ่านมา

    30s in, i think im from cat 5, i think i know what a monad is but i dont want to argue. one time i tried figuring it out on my own cause i was curious and any time i asked anyone for confirmation and they say "yeah", yet i think im wrong because its way simpler than anyone online says it is, "monoid in the category of endofunctors" "you lose the ability to explain it" and all
    my understanding is this
    "you take as input the state of everything and return everything but with the one 'side effect' you wanted changed, changed and it's technically not a sideffect anymore, and of course you dont actually change anything else so in machine code you just do the side effect and nothing else" please please tell me im wrong it cant be that theres a whole paradigm built on pure functions that just lies to itself

    • @SheafificationOfG
      @SheafificationOfG  6 วันที่ผ่านมา

      I think the problem is, if you water a concept down enough, it risks becoming oversimplified (and gives the impression that the concept is trivial or useless). The concept of a monad isn't too complicated at face value ("it just encodes computational effects / algebraic structure"), but when you make things precise, the nuances reveal themselves (as usual).
      From a functional programming pov, a monad is a way of modifying a type to encapsulate an additional computational effect, like you say. The idea is that you want to deal solely with composition of pure functions, and that's not friendly to side effects (a priori), so the monads give you a way of reinterpreting a function with side-effects as a pure function. This reinterpretation also makes analysing the program easier as well (as effects are more explicitly managed by the monadic structure).
      However, this is just the intuitive explanation; to really get it, you need to work through its explicit definition/axiomatisation (and maybe also try implementing the idea in your favourite language, like C++).
      I'm not sure what you mean when you say that the paradigm may be "lying to itself", so I can't really offer any insight in response to that one.

  • @SungKan-gv3yd
    @SungKan-gv3yd 5 วันที่ผ่านมา

    perfect introduction

  • @Seltyk
    @Seltyk 7 วันที่ผ่านมา

    Great video! I feel like this is the closest I've ever gotten to understanding fmap, join, and bind. I'm just… not *quite* there. I'm also unsure what monads can do that generically-typed structs (like std::pair) can't. Finally, the example used to demonstrate fmap glosses over what happens if the division function fails; it feels as though fmap is told "just assume no errors will occur and operate as if the types were X and Y instead of T(X) and T(Y)".

    • @SheafificationOfG
      @SheafificationOfG  7 วันที่ผ่านมา +1

      Thanks!
      Regarding your comment on generically-typed structs vs monads, I think the misconception is that monads are more of a "design pattern" than a "data structure". There are many ways you can *implement* a monad.
      For example, std::optional *is* an implementation of the Maybe monad (where the "new element" is std::nullopt). Of course, you can go your whole life without thinking about std::optional as a monad (or without even using std::optional, really), but the monad perspective can help you navigate your usage of std::optional.
      For example, if we use the pure implementation of division (4:33), how do we pass its output to is_pos? C++ will complain if you just pass a std::optional into is_pos, so you need to write a wrapper for is_pos to only deal with the "float part":
      if (input.has_value())
      { return is_pos(input); }
      else
      { return std::nullopt; }
      This wrapper is exactly fmap(is_pos).
      In particular, what you say about fmap really is what happens: fmap expresses how pure functions are completely unaware of any computational effects. If the input to fmap(is_pos) were an error (due to division by zero, say), the result of fmap(is_pos) is the same error. In particular, fmap isn't supposed to do anything too deep, and is just there to "correct the input/output types" of a pure function.

    • @Seltyk
      @Seltyk 2 วันที่ผ่านมา

      @@SheafificationOfG this makes a lot of sense for "programming on rails" monads like maybe, but what does fmap do with the state monad? My immediate guess would be that it executes the pure function then discards the state output, but that implementation removes logic which sounds silly

    • @SheafificationOfG
      @SheafificationOfG  2 วันที่ผ่านมา

      @Seltyk in general, fmap "passes effects along" through pure functions. If you have a pure function f : X -> Y, then fmap for the state monad transforms this function into a map Funcs(S, X x S) -> Funcs(S, Y x S). In other words, you can imagine the input of fmap(f) being "a value x that depends on state and, when obtained, alters the state", so the output is "the value f(x) that depends on the state and, when obtained, alters the state [where the effect on state is done when finding x before plugging into f]".
      If you try to use a pure function f : X -> Y and construct a function fmap(f) of the correct type, this is essentially the only natural way to do it.
      I hope this helps!

  • @chemicallife6108
    @chemicallife6108 12 วันที่ผ่านมา +2

    Well, i guess you could consider the TH-cam algorithm to be a bot. So, that last category fits everyone who didn't specifically look for this video.

  • @penand_paper6661
    @penand_paper6661 6 วันที่ผ่านมา

    The only thing that would make this even more complete would be discussion on monads in philosophy and in physics.
    Also I find it ridiculous that mathematicians just went ahead and said to itself, "I know there is 5 times 5, and there is 5 times X, but what if I did 5 times apple?" and just, invented a whole terminology for that.
    Preschooler-level creativity - which is creativity of the highest order.

    • @SheafificationOfG
      @SheafificationOfG  6 วันที่ผ่านมา

      Oh neat, what's a monad in physics? (Not that I really know what a monad in philosophy is, but I came across it while browsing for content...)

    • @penand_paper6661
      @penand_paper6661 6 วันที่ผ่านมา

      @@SheafificationOfG Oh hey, thanks for commenting!
      If you want, you could describe a Monad as being a "perfectly unified/most basic thing/concept, often which if the original Thing." Rather important in Greek philosophy. Plus, a lot of religions tend to think of God as a monad.
      It would be cool to see how this relates to math, including set theory and ideas of infinity (for example, you can use set theory to prove God cannot make a rock he can't lift, since that would involve making another God, or God being a self-defined thing with no need to have been created, but that's a whole discussion).
      I'd say the best advice is just to browse wikipedia on this and absorb whatever you can, and when you see something that looks like it intersects with your fields, dive into it properly.
      As for physics, I was thinking in terms of singularities, eg black holes, which arguably are unified point in the universe where the density is arguably infinite. You'll probably find making a vid on that much easier.

    • @SheafificationOfG
      @SheafificationOfG  6 วันที่ผ่านมา

      @@penand_paper6661 Ah, that description of the philosophical monad is roughly what I gathered from my 10s of browsing (definitely not my wheelhouse).
      Do physicists really refer to singularities as monads?

    • @penand_paper6661
      @penand_paper6661 6 วันที่ผ่านมา

      @@SheafificationOfG Truthfully, physics is not my area of expertise. However, I once saw the term used to describe singularities.
      I think you'd have a better time looking into the physics, as the math you worked with in the vid might have an application somehow there. (And since physics is basically applied maths.)

  • @sinom
    @sinom 5 ชั่วโมงที่ผ่านมา

    Also category 5
    But I'm also a postgrad CS student with a minor in maths. So it's at least kinda relevant to me

  • @ashleyzinyk399
    @ashleyzinyk399 6 วันที่ผ่านมา

    5th category; I've forgotten what monads are, so I feel that I need a reminder.

  • @Lexinathan
    @Lexinathan 10 วันที่ผ่านมา +1

    7:14
    Someone looked into Combinatorial Game Theory

  • @markusklyver6277
    @markusklyver6277 9 วันที่ผ่านมา

    I think the disagreement over what a function is is not so much its domain and codomain, but rather that a function in computers describe an algorithm to be run, i.e. a procedure. A mathematical function is not a procedure to run or to be evaluated, it just is. It is a common misconception that expressions like sin(e/pi) do not have an exact value, but indeed it is. sin(e/pi) is exactly sin(e/pi). What is commonly meant is that it isn't a computable or "calculable" number.
    But mathematical expressions or functions are not *procedures*, which is usually how more laymen people, applied mathematicians and computer scientists tend to view them.

    • @SheafificationOfG
      @SheafificationOfG  9 วันที่ผ่านมา

      Is it really common to believe that sin(e/pi) doesn't have an exact value?
      It may not have a closed form, but this number is "computable" (in the sense that there is an algorithm for computing sin(e/pi) to whatever desired precision in finite time).
      The discrepancy is definitely that mathematics views functions as a unique abstract association of an output (in the codomain) to any input (in the domain), whereas procedural programming views functions as an abstraction for parameterised computation. The point for introducing monads is just that they offer a way of reconciling the latter so that it can be studied as a mathematical (i.e., "pure") function, and remarkably this can be done by having a monad modify the codomain according to the type of effect the procedure has when executed.
      However, this is not to say that the discrepancy between functions in maths and CS is a matter of the choice of codomain. Monads are, of course, not the "be-all and end-all" of encoding procedures as (pure) functions: monads are only capable of encoding the "computational effects" of a procedure. It's not necessarily ideal for encoding so-called "computational context" (which affect the behaviour of the procedure)---such things are better suited to comonads.

    • @markusklyver6277
      @markusklyver6277 5 วันที่ผ่านมา

      @@SheafificationOfG And by "an abstraction for parameterised computation" you mean a procedure that eventually produces the desired output. I am arguing that this procedure-based view is a much more fundamental disagreement rather than the domain and codomain.

    • @SheafificationOfG
      @SheafificationOfG  5 วันที่ผ่านมา

      @@markusklyver6277 I agree with you that the procedural nature of functions in programming is definitely the more fundamental thing, but I'm just confused by what you mean regarding a "disagreement in co/domain"... I don't recall saying something along this line in the video.
      I (hopefully) didn't claim that all discrepancies can be resolved by having procedures appeal to co/monads to become pure functions, but the focus of the video was on monads, so naturally the discrepancy between math/cs functions that's important to me in this case is the presence of computational effects (which, of course, fall out of the procedural nature of these functions).

  • @furrball
    @furrball 10 วันที่ผ่านมา

    um... does a monad that returns a placeholder value consistent with the expected return value type, on failure, instead of throwing, still qualify as a maybe?

    • @SheafificationOfG
      @SheafificationOfG  10 วันที่ผ่านมา

      The maybe monad *always* extends a type to have a new element. If your implementation of division returns 0, say, when dividing by zero, then you actually just have a good old-fashioned pure function with no computational effects at all.

    • @furrball
      @furrball 9 วันที่ผ่านมา

      @@SheafificationOfG horay, thanks! I'll update my comments to call a certain collection of functions just functions, then. :)

  • @connorallen162
    @connorallen162 6 วันที่ผ่านมา

    I am my own functional programming friend, and I also have no idea what a monad is. Though understanding 20% of this video is as close as I've ever been

    • @SheafificationOfG
      @SheafificationOfG  6 วันที่ผ่านมา

      rare functional programmer who's on good terms with himself

  • @joedain7320
    @joedain7320 9 วันที่ผ่านมา

    To become closer with the Monad you must reject the earthly (demiurge) I recommend looking into the Pistis Sophia.

  • @codegeek98
    @codegeek98 7 วันที่ผ่านมา

    2:22 lol I'm more of a programmer, but this still got me 😅

  • @sayedizaanahmad
    @sayedizaanahmad 10 วันที่ผ่านมา +1

    6th category, learning maths

  • @davidebic
    @davidebic 7 วันที่ผ่านมา

    I now understand monads less than I did before this video

  • @propoppop9866
    @propoppop9866 9 วันที่ผ่านมา

    Yeah this feels like a case of computer scientists trying to align with maths when it dosent help

    • @SheafificationOfG
      @SheafificationOfG  8 วันที่ผ่านมา

      I understand your skepticism.
      As a programming paradigm, monads are particularly useful in the context of functional or compositional programming, where "state" (like global variables and whatnot) is otherwise more unnatural. The idea is maybe not so useful in procedural or object-oriented programming, but it can still appear as a useful design pattern in some contexts!

  • @GameJam230
    @GameJam230 12 วันที่ผ่านมา +1

    A monad is a monoid in the category of endofunctors 🕺

    • @SheafificationOfG
      @SheafificationOfG  12 วันที่ผ่านมา

      Dammit, I TOLD you not to say that!

    • @GameJam230
      @GameJam230 12 วันที่ผ่านมา

      @@SheafificationOfG The funny thing is, I haven't even watched far enough to hear you say that yet since I've been busy, I just came from the followup video to this one and had to say it 🤣. It was purely coincidental and reactionary lmao

  • @musicaltaco6803
    @musicaltaco6803 2 วันที่ผ่านมา

    Leibniz: Am I a joke to you?

  • @thezipcreator
    @thezipcreator 5 วันที่ผ่านมา

    I actually understand what the fuck a monad is now

  • @AnarchoAmericium
    @AnarchoAmericium 10 วันที่ผ่านมา

    Why am I watching this? I already know what a monad is. And a ringad for that matter.
    And operads.

    • @SheafificationOfG
      @SheafificationOfG  10 วันที่ผ่านมา

      Operads are *chef's kiss*
      but wtf is a "ringad"? An Ab-enriched monad?

  • @dr.mikelitoris
    @dr.mikelitoris 4 วันที่ผ่านมา

    can you do what is a gonad next

  • @comlitbeta7532
    @comlitbeta7532 8 วันที่ผ่านมา

    That I know fore sure. A monade is a monoïde in the category on andofunctir

  • @highxbye
    @highxbye 5 วันที่ผ่านมา

    Something seems to have gone wrong. These videos are starting to make some sense. I should check with my Psychiatrist.

    • @SheafificationOfG
      @SheafificationOfG  5 วันที่ผ่านมา

      Sending thoughts and prayers your way.

    • @highxbye
      @highxbye 5 วันที่ผ่านมา

      🙏

  • @danmar007
    @danmar007 9 วันที่ผ่านมา

    " they're just monoids in the category of endofunctors" 😛

  • @alexsampson2630
    @alexsampson2630 11 วันที่ผ่านมา

    A monoid in the category of endofunctors

  • @vtheselfdevotee111
    @vtheselfdevotee111 8 วันที่ผ่านมา

    YES! HE REFERENCED THE GNOSTIC MONAD< HAHAHAHAHAHA

  • @AlexTrusk91
    @AlexTrusk91 14 วันที่ผ่านมา

    I'm here thanks to the algorythm. I switched from math to cs like 2 years ago. I love math more, but it just didn't work out and it was on my part that I didn't bring more into thsi relationship.

    • @SheafificationOfG
      @SheafificationOfG  13 วันที่ผ่านมา +2

      I switched from CS back into math for grad school (what I'm trying to say is, math will always love you back).

  • @memyselfishness
    @memyselfishness 6 วันที่ผ่านมา

    Okay, but why didn't you discuss the monad of philosophy

  • @jon2422
    @jon2422 7 วันที่ผ่านมา

    This is my niche

  • @benoitcolotte406
    @benoitcolotte406 11 วันที่ผ่านมา

    Je me coupe une main si tu me dis que tu n'as pas fait l'ENS
    Gg la vidéo d'ailleurs, je salue le courage de s'aventurer sur un territoire aussi niche que les mathématiques de M2 👏

    • @SheafificationOfG
      @SheafificationOfG  11 วันที่ผ่านมา

      Désolé pour tes mains, mais je n'ai pas fait l'ENS !

  • @newtonswig
    @newtonswig 13 วันที่ผ่านมา

    Thanks man👨‍🍳💋👌

  • @Razumen
    @Razumen 9 วันที่ผ่านมา

    I'm ftom the mythical 5th category apparently.

  • @enricobianchi4499
    @enricobianchi4499 16 วันที่ผ่านมา

    What about in philosophy?

  • @admirljubovic6759
    @admirljubovic6759 7 วันที่ผ่านมา

    I am dissapointed in myself for liking this stuff

  • @A0V1
    @A0V1 10 วันที่ผ่านมา +1

    Im a bot? woa- *disapears*
    I am a catagory 5 hurri- I mean type of person. I have no idea what a monad is or why its important.

  • @Lucas-pj9ns
    @Lucas-pj9ns 9 วันที่ผ่านมา

    ow this makes my brain hurt so much

  • @anonamos225
    @anonamos225 10 วันที่ผ่านมา

    Is it a Proxy? It's definitely a Proxy. Idk I haven't seen the video yet.

    • @anonamos225
      @anonamos225 10 วันที่ผ่านมา

      After watching the entire video I was able to deduce that it was not, in fact, about anime.

    • @SheafificationOfG
      @SheafificationOfG  10 วันที่ผ่านมา

      Damn, I even watched Ergo Proxy, shame on me

  • @jumbeer5572
    @jumbeer5572 12 วันที่ผ่านมา

    Another subject Leibniz is into, crazy stuff

    • @SheafificationOfG
      @SheafificationOfG  12 วันที่ผ่านมา

      I don't think Leibniz was studying the same flavour of monad...

    • @jumbeer5572
      @jumbeer5572 11 วันที่ผ่านมา

      @@SheafificationOfG infact, just a joke, i probably got this recommended cuz of his monadology

  • @dakiitto
    @dakiitto 6 วันที่ผ่านมา

    certified CT classic

  • @emjizone
    @emjizone 10 วันที่ผ่านมา +1

    2:22 You bastard! Usual convention is that $g$ represent a function and $g(x)$ represent the *value* of that function for the number $x$, which are two completely different mathematical objects, of different type!
    Besides… you don't even need to suppose anything about $g(x)$ to simply take the data `g(x)=1` as it is, which is the answer to the question.
    Mathematicians answer $5$ , but the person who published this test is probably *not* a mathematician!

  • @monsieurLDN
    @monsieurLDN 8 วันที่ผ่านมา

    Bruh i got recommended 3 out of your 4 videos before this one made me click

    • @SheafificationOfG
      @SheafificationOfG  8 วันที่ผ่านมา

      I am inevitable
      (thanks for caving in)

  • @natebrown2805
    @natebrown2805 9 วันที่ผ่านมา

    category III gang lets go

  • @veeloth
    @veeloth 8 วันที่ผ่านมา

    As a bot I can confirm that I am indeed a bot

  • @wahidislamlinad
    @wahidislamlinad 6 วันที่ผ่านมา

    i liked what i saw

  • @user-qn2bg7zb9s
    @user-qn2bg7zb9s 8 วันที่ผ่านมา

    Hey, I'm a math enthusiast so...

  • @Morax___
    @Morax___ 11 วันที่ผ่านมา

    I click because monad sounded funny lol

  • @smithwillnot
    @smithwillnot 7 วันที่ผ่านมา

    I am from 6th category "Xenogears fan"

  • @TestHandlePleaseIgnore
    @TestHandlePleaseIgnore 6 วันที่ผ่านมา

    Beep boop

  • @andrewporter1868
    @andrewporter1868 วันที่ผ่านมา

    > axioms are defined by intent and purpose
    Absurd. This denies that anything has intrinsic whatness (essence) apart from any defined intent and purpose, reducing all that is certainly true and real to mere objects of man's willing things to be so. This is supremely absurd because one's self doesn't even exist as an object of one's own intent and purpose. QED
    Quite frankly, I can't tell if you're joking or not, but there's people out there who probably would believe it's not a joke on a whim because people today are naive and presumptuous.

    • @andrewporter1868
      @andrewporter1868 วันที่ผ่านมา

      > if g(1) is 5, then what is g(1)
      You just said it's 5, therefore g(1) is 5. The fact that a _procedure_ can have side effects which eventually can cause 5 to be a different result from a prior invocation to g(1) is accidental to the formal effect of g(x), therefore, etc.

    • @andrewporter1868
      @andrewporter1868 วันที่ผ่านมา

      > callme(5.0) ->5.0
      > callme(5.0) -> 6.0
      Function is a terrible name for a procedure anyways because it's quite clear it fails to meet the definition of a function according to mathematics. The only sense of the word function that makes sense here is "the function of a thing", i.e., behavior, but that also is retarded because not all procedures represent actions that belong to a particular nature, as ambulation belongs to n-peds (bipeds, quadrupeds, etc.), e.g., displacing which is common to all material bodies, but even pure spirits like the angels who have immaterial existences can displace.
      In any case, the point is that procedures are not strictly mathematical. Because they describe concrete action and the time in which they occur, they are metaphysical: and this is the subject of ontology, not mathematics. You can create mathematical entities that represent these things, but you cannot go the other way and transcend a mere mathematical object to an actually metaphysical object without some metaphysical entity (such as you or me) to bring it into existence. To claim otherwise is to err as Plato did who believed things like the ideal sphere are actually existing things in a different realm of existence. To make it purely mathematical, you would have to make a system of purely abstract action and abstract entities that can be affected by such action, but that already exists: it's called mathematics.

  • @sinnosanct
    @sinnosanct 13 วันที่ผ่านมา

    I don’t even know

  • @wearemaxandjustin9882
    @wearemaxandjustin9882 5 วันที่ผ่านมา

    What

  • @hlibprishchepov322
    @hlibprishchepov322 6 วันที่ผ่านมา

    Yep i am a bot

  • @Robotwesley
    @Robotwesley 9 วันที่ผ่านมา

    I’M A BOT!!!!

  • @ginogarcia8730
    @ginogarcia8730 12 วันที่ผ่านมา

    is it the male species chromosome / sexual cells holder?

    • @SheafificationOfG
      @SheafificationOfG  12 วันที่ผ่านมา +1

      Bruh 💀

    • @ginogarcia8730
      @ginogarcia8730 12 วันที่ผ่านมา

      @@SheafificationOfG haha thanks to the algo gods and you tho, been wanting to know what a monad is from Leibniz i think

    • @SheafificationOfG
      @SheafificationOfG  12 วันที่ผ่านมา +1

      @@ginogarcia8730 I may be mistaken, but I believe the "monads" Leibniz is talking about is a philosophical monad (which is a different kind than this video talks about). I'm no philosopher, so I'll just leave it at that.

    • @ginogarcia8730
      @ginogarcia8730 12 วันที่ผ่านมา

      @@SheafificationOfG ah, yeah little bit into the video I realized it haha - fascinating nonetheless

  • @joshuashoen14
    @joshuashoen14 11 วันที่ผ่านมา

    Im not from any of your four categories, im autistic

  • @Losid-ob5bz
    @Losid-ob5bz 9 วันที่ผ่านมา

    Monad proxy

  • @Freedom4Ever420
    @Freedom4Ever420 11 วันที่ผ่านมา

    I am bot

  • @ryanpmcguire
    @ryanpmcguire 7 วันที่ผ่านมา +1

    I have one functional programming friend. That is still one too many.

    • @mathephilia
      @mathephilia 2 วันที่ผ่านมา

      Hello, I am the functional programming friend. Though I don't get to use it enough as I'd like. 🥲 I am forced into an impure, crooked procedural world, like a lamb to the cosmic slaughter.

  • @the-one-who-asked
    @the-one-who-asked 10 วันที่ผ่านมา

    shit i am a bot