:: String -> Maybe Int -package:happstack-server
Read a positive
Int, accounting for overflow
Parse seed argument
>>> parseSeed "--seed=6"
Just 6
>>> parseSeed "--seeeed=6"
Nothing
Parse number of threads argument
>>> parseThreads "-j6"
Just 6
>>> parseThreads "-j-2"
Nothing
>>> parseThreads "-jA"
Nothing
Returns the operator precedence of an infix string.
> outernmostPrec "1 + 2"
Just 6
Lookup a terminal capability that has an integer value
throws
ExpectFailed. This is nice for writing your own
abstractions.
A convenience function for throwing a user error. This is useful for
cases where it would be too high a burden to define your own exception
type.
This throws an exception of type
StringException. When GHC
supports it (base 4.9 and GHC 8.0 and onward), it includes a call
stack.
Lifted version of
die.
>>> die "Goodbye!"
Goodbye!
*** Exception: ExitFailure 1
Lifted version of
die.
die is available since base-4.8,
but it's more convenient to redefine it instead of using CPP.
When you encounter an error where the only sane way to handle it is to
write an error to the log and die messily, use fatalError. This is a
good candidate for things like not being able to find configuration
files on startup.
General-purpose function to throw a test exception with a
String.
Throws a
Pending exception with a message to add additional
details.
Fail with a message. This operation is not part of the mathematical
definition of a monad, but is invoked on pattern-match failure in a
do expression.
As part of the MonadFail proposal (MFP), this function is moved to its
own class
MonadFail (see
Control.Monad.Fail for more
details). The definition here will be removed in a future release.
The type-safe cast operation
Cast a value to a different type.
Essentially this is just a drop-in replacement for
cast.
Throw an error, escaping the current computation up to the nearest
catchError (if any).
runThrow (throwError e >>= k) = runThrow (throwError e)