Are there any good videos explaining monads in Haskell?

Most videos are about the concept of Monads in general. So far I only know three things from the ones I've watched:

> the bind operator takes a monad, unwraps it's value, applies a function to it and then returns another monad
> Maybe, Writer and IO are monads
> They're monoids in the category of endofunctors

This doesn't teach me how to write code with it, though.

Shopping Cart Returner Shirt $21.68

Yakub: World's Greatest Dad Shirt $21.68

Shopping Cart Returner Shirt $21.68

  1. 6 days ago
    Anonymous

    Watch russian incel Tsoding he has good haskell vids

  2. 6 days ago
    Anonymous

    unironically ask chatgpt

  3. 6 days ago
    Anonymous

    >the bind operator takes a monad, unwraps it's value
    literally how? i thought unwrapping wasn't possible

    • 6 days ago
      Anonymous

      I have no fricking idea, but it was in the tutorials.

  4. 6 days ago
    Anonymous

    just try writing some haskell code. it'll sink in after a while

    • 6 days ago
      Anonymous

      I did.
      Even yesterday I posted a snippet of a code of mine on StackOverflow and they're tearing it to shreds until now (But at least I got some useful lessons and optimized it to the way it is now).

      The things is... I still haven't used Monads outside of "IO()" for the mains functions... which I don't know how it works, but I know it works.

      • 6 days ago
        Anonymous

        try using monads for something other than IO stuff. for example, try using lists as a monad. exercise: what does this code do? (feel free to run it to figure it out. if it doesn't work then figure out how to fix it)

        import Control.Monad

        list = do
        jak <- ["chud", "feral", "cobson", "nojak"]
        rating <- ["forced coal", "a gem", "iron", "brimstone"]
        pure $ jak ++ " is " ++ rating

        main = forM_ list print

  5. 6 days ago
    Anonymous

    explain monads in 2 sentences or less

    • 6 days ago
      Anonymous

      monoid in the category of endofunctors.

  6. 6 days ago
    Anonymous

    No. Either learn category theory or just use them until you intuit them. It's not hard.

    • 6 days ago
      Anonymous

      That's not the issue, anon.
      It's not that I've watched 500 videos about monads in Haskell, but rather that I only found 1-2 videos of Monads in Haskell, and all the others are of Monads in general.

      Will category theory teach me how do create a monadic function in Haskell? No.
      Will it teach me wtf ">>" does? Also no.

      What will? IDK, that's why I'm here asking.

      • 6 days ago
        Anonymous

        Just keep making things in Haskell then. There's no substitute for practice.

        • 6 days ago
          Anonymous

          Anon, you don't understand.
          I'm literally at "Zero": No matter how much you multiply it, it is still Zero.
          I want to know if there are any good videos where my knowledge of it can go to a positive non-Zero number.
          THEN I can practice.

          I can't "keep making things in Haskell" if I don't even know how to make the first thing.

          try using monads for something other than IO stuff. for example, try using lists as a monad. exercise: what does this code do? (feel free to run it to figure it out. if it doesn't work then figure out how to fix it)

          import Control.Monad

          list = do
          jak <- ["chud", "feral", "cobson", "nojak"]
          rating <- ["forced coal", "a gem", "iron", "brimstone"]
          pure $ jak ++ " is " ++ rating

          main = forM_ list print

          Well, my knowledge in Haskell tells me that this would concatenate two lists.
          What happened when I executed it, however, seemed like a list comprehension, for which I have no idea how you did it.
          How the frick is this supposed to teach me about monads?

          >Will category theory teach me how do create a monadic function in Haskell? No.
          what do you mean by a monadic function?
          >Will it teach me wtf ">>" does? Also no.
          you can look it up using hoogle
          https://hoogle.haskell.org/?hoogle=%3E%3E
          then you click on the first result and go to
          https://hackage.haskell.org/package/base-4.19.1.0/docs/Prelude.html#v:-62--62-
          this goes to the documentation, which describes (>>) in plain english. you can also go to the definition of (>>) from there, as most operators in haskell are defined in a way similar to functions

          >what do you mean by a monadic function?

          A function that works with monads.
          If this phrase doesn't make sense, is because I'm new to this.

          >Sequentially compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.

          That seems like a contradictory explanation: Wasn't composition when you piped the output of a function as the input of another, like when you use (.)?
          Also, why would I want to use a function and then discard it's results? Isn't the whole point of Haskell that functions only produce results, and not side-effects?

          And also, why the frick something like "Nothing >> (Just 5) returns me Nothing? Wasn't it supposed to return the value of the second argument?

          • 6 days ago
            Anonymous

            >

            try using monads for something other than IO stuff. for example, try using lists as a monad. exercise: what does this code do? (feel free to run it to figure it out. if it doesn't work then figure out how to fix it)

            import Control.Monad

            list = do
            jak <- ["chud", "feral", "cobson", "nojak"]
            rating <- ["forced coal", "a gem", "iron", "brimstone"]
            pure $ jak ++ " is " ++ rating

            main = forM_ list print (You) #
            >Well, my knowledge in Haskell tells me that this would concatenate two lists.
            >What happened when I executed it, however, seemed like a list comprehension, for which I have no idea how you did it.
            >How the frick is this supposed to teach me about monads?
            i was hoping you'd try to figure out how it worked
            here's a simpler example:
            xyz = do
            a <- [1..5]
            b <- [1..a]
            pure (a, b)

            >

            >Will category theory teach me how do create a monadic function in Haskell? No.


            what do you mean by a monadic function?
            >Will it teach me wtf ">>" does? Also no.
            you can look it up using hoogle
            https://hoogle.haskell.org/?hoogle=%3E%3E
            then you click on the first result and go to
            https://hackage.haskell.org/package/base-4.19.1.0/docs/Prelude.html#v:-62--62-
            this goes to the documentation, which describes (>>) in plain english. you can also go to the definition of (>>) from there, as most operators in haskell are defined in a way similar to functions (You) #
            >>what do you mean by a monadic function?
            >A function that works with monads.
            >If this phrase doesn't make sense, is because I'm new to this.
            working with monads isn't really any different from working with "non-monads"

            compose two actions, discarding any value produced by the first, like sequencing operators (such as the semicolon) in imperative languages.
            >That seems like a contradictory explanation: Wasn't composition when you piped the output of a function as the input of another, like when you use (.)?
            >Also, why would I want to use a function and then discard it's results? Isn't the whole point of Haskell that functions only produce results, and not side-effects?
            >And also, why the frick something like "Nothing >> (Just 5) returns me Nothing? Wasn't it supposed to return the value of the second argument?

            the most obvious answer is: look at the fricking code! see how >> is defined in Control.Monad

            as for why it would be defiend that way: try defining your own version of Maybe (call it MyMaybe or something) and figure out how to implement Monad MyMaybe in a way that makes sense (that is, follows the monad laws and basic haskell practice like avoiding partial functions)

          • 6 days ago
            Anonymous

            off the top of my head, the definition will be equivalent to
            a >> b = a >>= (dummy -> b)

          • 6 days ago
            Anonymous

            >i was hoping you'd try to figure out how it worked
            >here's a simpler example:
            >xyz = do
            > a <- [1..5]
            > b <- [1..a]
            > pure (a, b)

            I have no idea of what "pure" is..

            >the most obvious answer is: look at the fricking code! see how >> is defined in Control.Monad

            Where?
            If you're talking about here(https://hackage.haskell.org/package/base-4.19.1.0/docs/Prelude.html#v:-62--62-), it was from here that I took that quote.
            That doesn't tell me anything, it doesn't show me how it was implemented.

            >as for why it would be defiend that way: try defining your own version of Maybe (call it MyMaybe or something) and figure out how to implement Monad MyMaybe in a way that makes sense (that is, follows the monad laws and basic haskell practice like avoiding partial functions)

            How am I supposed to implement a Monad if I don't know how Monads work?

            >No matter how much you multiply it, it is still Zero.
            So you build new knowledge additively, which takes hard work.

            >So you build new knowledge additively, which takes hard work.
            No fricking shit?
            If only I made a thread on IQfy asking for videos where I could attain such new additive knowledge...

            off the top of my head, the definition will be equivalent to
            a >> b = a >>= (dummy -> b)

            Then why does "Nothing >> (Just 5)" returns Nothing, and not Just 5?

          • 6 days ago
            Anonymous

            it literally shows you how (>>) is implemented in terms of (>>=)
            you can also look up how Monad Maybe implements (>>=). it should be under Data.Maybe or under Control.Monad

            >working with monads isn't really any different from working with "non-monads"
            I don't ever remember seen an asterisk when working with non-monads
            I have no idea why this is "wrong">

            Maybe is a type, not a typeclass, so you shouldn't write a type signature like Maybe m => ...

            unironically go to r/haskell, you'll get a lot more help there from kind and experienced haskellers

          • 6 days ago
            Anonymous

            >it literally shows you how (>>) is implemented in terms of (>>=)
            Where?

            >Maybe is a type, not a typeclass
            I'm not familiar with the difference, I only started studying Haskell a week ago.

          • 6 days ago
            Anonymous

            See how it says “# source” on the right? Click on that

          • 6 days ago
            Anonymous

            I see now, thanks.

            Still, it doesn't answer why something like "Nothing >> Just 5" returns Nothing.
            I though that internally it had some special check.

          • 6 days ago
            Anonymous

            Look at how “Monad Maybe” is implemented. Should be in Data.Maybe
            Then you can put the pieces together to see what >> does for Maybe
            go to r/haskell for more help

          • 6 days ago
            Anonymous

            Read a book, and DON'T skip directly to the monads chapter
            https://learnyouahaskell.github.io/

            Reddit is obsolete, use https://discourse.haskell.org

          • 6 days ago
            Anonymous

            >working with monads isn't really any different from working with "non-monads"
            I don't ever remember seen an asterisk when working with non-monads
            I have no idea why this is "wrong">

          • 6 days ago
            Anonymous

            >No matter how much you multiply it, it is still Zero.
            So you build new knowledge additively, which takes hard work.

  7. 6 days ago
    Anonymous
  8. 6 days ago
    Anonymous

    >Will category theory teach me how do create a monadic function in Haskell? No.
    what do you mean by a monadic function?
    >Will it teach me wtf ">>" does? Also no.
    you can look it up using hoogle
    https://hoogle.haskell.org/?hoogle=%3E%3E
    then you click on the first result and go to
    https://hackage.haskell.org/package/base-4.19.1.0/docs/Prelude.html#v:-62--62-
    this goes to the documentation, which describes (>>) in plain english. you can also go to the definition of (>>) from there, as most operators in haskell are defined in a way similar to functions

    • 6 days ago
      Anonymous

      meant for

      That's not the issue, anon.
      It's not that I've watched 500 videos about monads in Haskell, but rather that I only found 1-2 videos of Monads in Haskell, and all the others are of Monads in general.

      Will category theory teach me how do create a monadic function in Haskell? No.
      Will it teach me wtf ">>" does? Also no.

      What will? IDK, that's why I'm here asking.

  9. 6 days ago
    Anonymous

    try to think of a monad as a box holding something (a unit of computation, a value, a side effect, etc.). manipulations and more downstream tasks can then be performed based on the contents of the monad (box) using operations like flatmap.

Your email address will not be published. Required fields are marked *