E
E
Eugenue Cesarevich2020-09-10 20:59:16
Java
Eugenue Cesarevich, 2020-09-10 20:59:16

What is a monad?

Trying to understand what a monad is. Dictionary definition:

it is an abstraction of a linear chain of related computations

What the author was trying to say by this, I have no idea (in other sources the definition is no better). I came across this term while reading about Stream in Java8. Here is the quote:
Streams are Monads that play a big role in enabling functional programming in Java.


What does it mean? Can you explain in simple terms what a monad is?

Answer the question

In order to leave comments, you need to log in

5 answer(s)
O
Orkhan, 2020-09-10
@cot_shaurma

Here, a simple explanation - https://urvanov.ru/2017/10/18/%D0%BC%D0%BE%D0%BD%D...

S
Sergey Gornostaev, 2020-09-11
@sergey-gornostaev

Monoid in the category of endofunctors.

P
pazukdev, 2020-12-13
@pazukdev

A monad is an abstraction over a chain of related computations. A container that takes the current state and a function that takes that state as an argument and returns the new state. This container encapsulates the environment (context) for performing calculations, taking into account possible exceptions; the output is only the expected values. In general, just a monoid in the category of endofunctors (c).

A
Alexander Skusnov, 2020-09-11
@AlexSku

There is a usual calculation a -> b
. Monads implement calculations with effects:
Maybe - there may be failure,
List - many results,
Either - typed exceptions,
(s, b) - writing to the log,
( (->) e ) b - reading from external environment,
(State s) b - mutable states,
IO b - I/O (console, files).
(examples for Haskel)

M
Mikhail Potanin, 2022-03-03
@potan

A monad is a common interface that allows you to work with very different entities in a unified way, such as lists, parsers, IO operations (both synchronous and asynchronous).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question