Some languages and uses for monads
According to you, which language do you 开发者_C百科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
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.
In order of preference:
- Haskell
- F#
- Scala
- C#
Monads in order of decreasing simplicity:
- Maybe (Exception)
- Reader
- Writer
- State
- Parser
- Async
Here are some tutorial that use clojure. Monads are implemented in a library.
- http://onclojure.com/2009/03/05/a-monad-tutorial-for-clojure-programmers-part-1/
- http://onclojure.com/2009/03/06/a-monad-tutorial-for-clojure-programmers-part-2/
- http://onclojure.com/2009/03/23/a-monad-tutorial-for-clojure-programmers-part-3/
For examples, see Philip Wadler, "Monads for functional programming".
精彩评论