HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Modulebase-4.20.2.0Haskell2010

GHC.Maybe

The Maybe type.

  • 1 type
  • Packagebase-4.20.2.0
  • Exports1
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceMaybe.hs
datadata Maybe a
#

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 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 Either type.

Constructors

Instances30Monad, Functor, MonadFix, MonadFail, Applicative, Foldable, …