summaryrefslogtreecommitdiff
path: root/libraries/base/GHC/Maybe.hs
diff options
context:
space:
mode:
authorKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
committerKavon Farvardin <kavon@farvard.in>2018-09-23 15:29:37 -0500
commit84c2ad99582391005b5e873198b15e9e9eb4f78d (patch)
treecaa8c2f2ec7e97fbb4977263c6817c9af5025cf4 /libraries/base/GHC/Maybe.hs
parent8ddb47cfcf5776e9a3c55fd37947c8a95e00fa12 (diff)
parente68b439fe5de61b9a2ca51af472185c62ccb8b46 (diff)
downloadhaskell-wip/T13904.tar.gz
update to current master againwip/T13904
Diffstat (limited to 'libraries/base/GHC/Maybe.hs')
-rw-r--r--libraries/base/GHC/Maybe.hs31
1 files changed, 31 insertions, 0 deletions
diff --git a/libraries/base/GHC/Maybe.hs b/libraries/base/GHC/Maybe.hs
new file mode 100644
index 0000000000..2bdfac54a2
--- /dev/null
+++ b/libraries/base/GHC/Maybe.hs
@@ -0,0 +1,31 @@
+{-# LANGUAGE NoImplicitPrelude #-}
+
+-- | Maybe type
+module GHC.Maybe
+ ( Maybe (..)
+ )
+where
+
+import GHC.Integer () -- See Note [Depend on GHC.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
+ )