File: maybe.verb

package info (click to toggle)
haskell98-report 20030706-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 1,888 kB
  • ctags: 77
  • sloc: haskell: 3,809; makefile: 326; sh: 4
file content (30 lines) | stat: -rw-r--r-- 804 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
%**<title>The Haskell 98 Library Report: Maybe Utilities</title>
%**~header
\section{Maybe Utilities}

\outline{
\inputHS{headers/Maybe}
}

The type constructor @Maybe@ is defined in @Prelude@ as
\bprog
@
data Maybe a = Nothing | Just a
@
\eprog
The purpose of the @Maybe@ type is to provide a method of dealing with
illegal or optional values without terminating the program, as would
happen if @error@ were used, and without using @IOError@ from the @IO@
monad, which would cause the expression to become monadic.  A correct
result is encapsulated by wrapping it in @Just@; an incorrect result
is returned as @Nothing@.

Other operations on @Maybe@ are provided as part of the monadic
classes in the Prelude.

\clearpage
\subsection{Library {\tt Maybe}}
\label {Maybe}
\inputHS{code/Maybe}

%**~footer