According to you, which language do you think would be the best for implementing monads (Python/Ruby/LISP)?,also can anyone tell me some possible uses of monads (please give examples),like exceptions?
Thanks in advance
A monad is an algebraic structure in category theory, and in Haskell it is used to describe computations as sequences of steps, and to handle side effects such as state and IO. Monads are abstract, and they have many useful concrete instances. Monads provide a way to structure a program.
Monads are a very interesting and powerful design pattern in Functional languages that can be applied in Python to enable things such as elegant error handling or turning your code into lazily evaluated pipelines with no changes to the code itself.
The key idea of a monad is that a monad encapsulates a simple type in an enriched type and supports the compositions of functions on these enriched types. Therefore, the monad needs a function for lifting the simple type into an enriched type.
All About Monads - legendary tutorial that lists all the standard monads and gives a lot of real-world examples.
Popular monads that you can meet even in the mainstream languages are Maybe
, List
and Continuation
.
Some people also think that jQuery itself is a monad (as it follows the monadic axioms).
As for the language choice, Haskell and its derivatives are using monads as a fundamental concept, however, as an option, constructing monads is possible in a lot of modern languages. In order to familiarize with the monad concept I'd better choose the language I'm the most comfortable with.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With