Monads/Maybe monad

From Rosetta Code
Revision as of 03:47, 1 February 2016 by rosettacode>Domgetter (created Maybe monad page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Demonstrate in your programming language the following:

  1. Construct a Maybe Monad by writing the 'bind' function and the 'unit' (sometimes known as 'return') function for that Monad (or just use what the language already has implemented)
  2. Make two functions, each which take a number and return a monadic number, e.g. Int -> Maybe Int and Int -> Maybe String
  3. Compose the two functions with bind