blob: 0e45e80707bef42c30993901f28dc85982b6a2e1 (
plain)
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
31
32
|
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_HADDOCK not-home #-}
-- | Maybe type
module GHC.Maybe
( Maybe (..)
)
where
import GHC.Num.Integer () -- See Note [Depend on GHC.Num.Integer] in GHC.Base
import GHC.Classes
default ()
-------------------------------------------------------------------------------
-- Maybe type
-------------------------------------------------------------------------------
-- | The 'Maybe' type encapsulates an optional value. A value of type
-- @'Maybe' a@ either contains a value of type @a@ (represented as @'Just' a@),
-- or it is empty (represented as 'Nothing'). Using 'Maybe' is a good way to
-- deal with errors or exceptional cases without resorting to drastic
-- measures such as 'Prelude.error'.
--
-- The 'Maybe' type is also a monad. It is a simple kind of error
-- monad, where all errors are represented by 'Nothing'. A richer
-- error monad can be built using the 'Data.Either.Either' type.
--
data Maybe a = Nothing | Just a
deriving ( Eq -- ^ @since 2.01
, Ord -- ^ @since 2.01
)
|