I have learned to love the monad

I have learned to love the monad.

Attached: images.png (327x154, 2K)

Other urls found in this thread:

blog.merovius.de/2018/01/08/monads-are-just-monoids.html
adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html
twitter.com/NSFWRedditImage

>literally a constructor
You're not that smart, kid.

Attached: brainlettttt.jpg (800x450, 44K)

That logo looks lewd.

Why?

I kinda see two persons and a benis. Maybe I should go out more. At least it is not that OpenSUSE modified logo.

Is functional programming an academic meme or does it have legitimate use cases?

Yes

Haskell is an academic meme but Clojure and Erlang have seen legitimate uses in industry.

So Jow Forums, what exactly is a monad?

Attached: bananasmug.png (500x500, 181K)

I think the monad is "scary" because books and sites explain it before properly describing types, kinds and type constructors, so the "m a" notation confuses them. At least I was.

A type that implements the "pure" and "bind" operator.

That, and it's generally agreed they should behave in a certain way. But nobody cares.

Do you want the mathematical explanation, the practical explanation, or the meme explanation?

A monad is a burrito.

Because it makes white people shit themselves?

cringe

> Constructor
A *composable* constructor

Pure is applicative functor bind is join compost with map/fmap. - join is the monad magic

First for unironically enjoying this language.

so if you have a type MyType that takes a parameter type like a list so you can have a list of, say integers, then you have a functor (once you implement map

map :: (a -b) -> f a -> f b

map takes some function that works on a's and turns it into a function that works on a's within a context f, such as a list of f.

then applicative is a functor that can put any arbitrary value into a minimal functor, this is called 'pure' or 'return' not all functors can do this, but it's usually the constructor, applicative usually also includes a function called 'ap' or 'apply' which is for when you have a function in your functor, and you want to take that function out and map it over some other functor of the same type,

pure :: a -> f a
ap :: f (a -> b) -> f a -> f b

then monad has join which is for getting rid of nested structure,. so if you can have a list of lists, you can flatten it into a single list.

join :: m (m a) -> m a

monads are always applicatives and functors. but once a structure has the monad capability, you can force sequential action within a lazy language (you can do this with applicative too, but it's traditionally monad that we use)

not op but,
all three please.

Mathematical:
blog.merovius.de/2018/01/08/monads-are-just-monoids.html
Practical:
adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html

A monad is a monad in the category of endofunctors.

Monad is a type class providing the following functions
return :: Monad m => a -> m a
bind :: Monad m => m a -> (a -> m b) -> m b
(join can also be used instead of bind, and bind is typically written as the operator >>=)
A monad is a burrito.

*monoid in the category of endofunctors

>A monad is a monad in the category of endofunctors.

To add to what the others said, a very informal explanation: Monads enable you to make stuff happen depending of previous stuff. For example you could read some user input and return a 1 if the input was "yes" and a 0 if the input was "no". Here the number we return depends on something else, namely the user input. Sounds trivial, but is needed in Haskell for good reasons.

Academic meme and waste of time.

Nah, it's fun and programs written in it are fast, do their job and don't have bugs like NullPointerExceptions. I mean imagine if your code containted NullPointerExceptions lmao

You h/\ve been visited by L`aur/\ Dy/\tlov.

This th^read is current*ly rea|ding 28 repli*es (n*ot gre`at, not te^rrible).

Attached: 1532463261185.jpg (1199x599, 115K)