option -package:attoparsec

option x p will either parse p or return x without consuming any input.
option x p tries to apply parser p. If p fails without consuming input, it returns the value x, otherwise the value returned by p.
priority  = option 0 (do{ d <- digit
; return (digitToInt d)
})
Create an option taking a single OptDescr. No explicit Name is given for the Option, the name is the first LFlag given. Example: option sf lf d get set * sf: Short option name, for example: ['d']. No hyphen permitted. * lf: Long option name, for example: ["debug"]. No hyphens permitted. * d: Description of the option, shown to the user in help messages. * get: Get the current value of the flag. * set: Set the value of the flag. Gets the current value of the flag as a parameter.
Not on Stackage, so not searched. A strict version of Maybe
When invoking external tools as part of the compilation pipeline, we pass these a sequence of options on the command-line. Rather than just using a list of Strings, we use a type that allows us to distinguish between filepaths and 'other stuff'. The reason for this is that this type gives us a handle on transforming filenames, and filenames only, to whatever format they're expected to be on a particular platform.
One or none. It is useful for modelling any computation that is allowed to fail.

Examples

Using the Alternative instance of Control.Monad.Except, the following functions:
>>> import Control.Monad.Except
>>> canFail = throwError "it failed" :: Except String Int

>>> final = return 42                :: Except String Int
Can be combined by allowing the first function to fail:
>>> runExcept $ canFail *> final
Left "it failed"
>>> runExcept $ optional canFail *> final
Right 42
optional p optionally parses p and always returns ().
optionMaybe p tries to apply parser p. If p fails without consuming input, it return Nothing, otherwise it returns Just the value returned by p.
optional p tries to apply parser p. It will parse p or nothing. It only fails if p fails after consuming input. It discards the result of p.
A human-readable description of the option to guide the user setting it.