Concept:Maybe monad
== Headline ==
A [[monad]] for dealing with partiality or error handling
== Illustration ==
Let us put to work the Maybe monad in a simple interpreter.
=== A baseline interpreter ===
There are these expression forms for floats, addition, and square roots:
<syntaxhighlight lang="haskell">
-- Simple arithmetic expressions
data Expr = Constant Float | Add Expr Expr | Sqrt Expr
deriving (Eq, Show, Read)
</syntaxhighlight>
Consider these samples:
<syntaxhighlight lang="haskell">
-- Sample terms
sample = Sqrt (Constant 4)