Monads: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 7:
 
# 'Return' which wraps a piece of raw data, returning the wrapped 'monadic' form
# 'Bind' which applies some other function directly to the contents of a monadic wrapper, obtains a result, and returns a wrapped monadic form of that result.
 
Commonly used monads include the Maybe monad, (in which the wrapper encodes whether or not the raw content is a legal value for a particular type of function), and the List monad, in which raw data is simply contained in a list. When lists are used to represent a range of possible values for a variable name, nesting functions which act on these lists allows a convenenient encoding of cartesian products and set comprehensions. In this context, the two higher order monad functions ensure that each data-transforming function gets and returns the right kind of argument (Raw atomic values versus one or more values 'wrapped in' a list).
9,655

edits