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 |

Shopping Cart Returner Shirt $21.68 |

Watch russian incel Tsoding he has good haskell vids

unironically ask chatgpt

>the bind operator takes a monad, unwraps it's value

literally how? i thought unwrapping wasn't possible

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

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

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.

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

explain monads in 2 sentences or less

monoid in the category of endofunctors.

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

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.

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

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.

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?

>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?

>

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)

>

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)

off the top of my head, the definition will be equivalent to

a >> b = a >>= (dummy -> b)

>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?

>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...

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

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

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

>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.

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

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.

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

Read a book, and DON'T skip directly to the monads chapter

https://learnyouahaskell.github.io/

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

>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">

>No matter how much you multiply it, it is still Zero.

So you build new knowledge additively, which takes hard work.

>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

meant for

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.