Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creative uses of monads

Tags:

haskell

monads

I'm looking for creative uses of monads to learn from. I've read somewhere that monads have been used for example in AI, but being a monad newbie, I fail to see how.

Please include a link to the source code and sample usages. No standard monads please.

like image 302
Mauricio Scheffer Avatar asked Jan 05 '09 12:01

Mauricio Scheffer


People also ask

What are monads useful for?

monads are used to address the more general problem of computations (involving state, input/output, backtracking, ...) returning values: they do not solve any input/output-problems directly but rather provide an elegant and flexible abstraction of many solutions to related problems.

What are monads explain with example?

In functional programming, a monad is a software design pattern with a structure that combines program fragments (functions) and wraps their return values in a type with additional computation.

Why is a monad called a monad?

The term monad (from Ancient Greek μονάς (monas) 'unity', and μόνος (monos) 'alone') is used in some cosmic philosophy and cosmogony to refer to a most basic or original substance. As originally conceived by the Pythagoreans, the Monad is the Supreme Being, divinity or the totality of all things.

What is a monad in simple terms?

So in simple words, a monad is a rule to pass from any type X to another type T(X) , and a rule to pass from two functions f:X->T(Y) and g:Y->T(Z) (that you would like to compose but can't) to a new function h:X->T(Z) .


1 Answers

Phil Wadler has written many papers on monads, but the one to read first is a lot of fun and will be accessible to any programmer; it's called The essence of functional programming. The paper includes source code and sample usages.

A personal favorite of mine is the probability monad; if you can find Sungwoo Park's PhD thesis, it has a number of interesting example codes from robotics.

like image 124
Norman Ramsey Avatar answered Sep 17 '22 18:09

Norman Ramsey