Chessie


Trial

Namespace: Chessie.ErrorHandling

Basic combinators and operators for error handling.

Nested types and modules

TypeDescription
TrialBuilder

Builder type for error handling computation expressions.

Functions and values

Function or valueDescription
( <!> ) f result
Signature: f:('?7270 -> '?7271) -> result:Result<'?7270,'?7272> -> Result<'?7271,'?7272>
Type parameters: '?7270, '?7271, '?7272

Lifts a function into a Result and applies it on the given result. This is the infix operator version of ErrorHandling.lift

CompiledName: op_LessBangGreater

( <*> ) wrappedFunction result
Signature: wrappedFunction:Result<('?7258 -> '?7259),'?7260> -> result:Result<'?7258,'?7260> -> Result<'?7259,'?7260>
Type parameters: '?7258, '?7259, '?7260

If the wrapped function is a success and the given result is a success the function is applied on the value. Otherwise the exisiting error messages are propagated. This is the infix operator version of ErrorHandling.apply

CompiledName: op_LessMultiplyGreater

( >>= ) result f
Signature: result:Result<'?7250,'?7251> -> f:('?7250 -> Result<'?7252,'?7251>) -> Result<'?7252,'?7251>
Type parameters: '?7250, '?7251, '?7252

If the result is a Success it executes the given function on the value. Otherwise the exisiting failure is propagated. This is the infix operator version of ErrorHandling.bind

CompiledName: op_GreaterGreaterEquals

apply wrappedFunction result
Signature: wrappedFunction:Result<('?7254 -> '?7255),'?7256> -> result:Result<'?7254,'?7256> -> Result<'?7255,'?7256>
Type parameters: '?7254, '?7255, '?7256

If the wrapped function is a success and the given result is a success the function is applied on the value. Otherwise the exisiting error messages are propagated.

bind f result
Signature: f:('?7243 -> Result<'?7244,'?7245>) -> result:Result<'?7243,'?7245> -> Result<'?7244,'?7245>
Type parameters: '?7243, '?7244, '?7245

If the result is a Success it executes the given function on the value. Otherwise the exisiting failure is propagated.

Catch f x
Signature: f:('?7227 -> '?7228) -> x:'?7227 -> Result<'?7228,exn>
Type parameters: '?7227, '?7228

Executes the given function on a given success or captures the exception in a failure

collect xs
Signature: xs:seq<Result<'?7288,'?7289>> -> Result<'?7288 list,'?7289>
Type parameters: '?7288, '?7289

Collects a sequence of Results and accumulates their values. If the sequence contains an error the error will be propagated.

either fSuccess fFailure trialResult
Signature: fSuccess:('?7233 * '?7234 list -> '?7235) -> fFailure:('?7234 list -> '?7235) -> trialResult:Result<'?7233,'?7234> -> '?7235
Type parameters: '?7233, '?7234, '?7235

Takes a Result and maps it with fSuccess if it is a Success otherwise it maps it with fFailure.

eitherTee fSuccess fFailure result
Signature: fSuccess:('?7279 * '?7280 list -> unit) -> fFailure:('?7280 list -> unit) -> result:Result<'?7279,'?7280> -> Result<'?7279,'?7280>
Type parameters: '?7279, '?7280

If the result is a Success it executes the given success function on the value and the messages. If the result is a Failure it executes the given failure function on the messages. Result is propagated unchanged.

fail msg
Signature: msg:'Message -> Result<'TSuccess,'Message>
Type parameters: 'TSuccess, 'Message

Wraps a message in a Failure

failed result
Signature: result:Result<'?7230,'?7231> -> bool
Type parameters: '?7230, '?7231

Returns true if the result was not successful.

failIfNone message result
Signature: message:'?7291 -> result:'?7292 option -> Result<'?7292,'?7291>
Type parameters: '?7291, '?7292

Converts an option into a Result.

failOnWarnings result
Signature: result:Result<'?7300,'?7301> -> Result<'?7300,'?7301>
Type parameters: '?7300, '?7301
failureTee f result
Signature: f:('?7285 list -> unit) -> result:Result<'?7286,'?7285> -> Result<'?7286,'?7285>
Type parameters: '?7285, '?7286

If the result is a Failure it executes the given function on the messages. Result is propagated unchanged.

flatten result
Signature: result:Result<Result<'?7247,'?7248>,'?7248> -> Result<'?7247,'?7248>
Type parameters: '?7247, '?7248

Flattens a nested result given the Failure types are equal

lift f result
Signature: f:('?7262 -> '?7263) -> result:Result<'?7262,'?7264> -> Result<'?7263,'?7264>
Type parameters: '?7262, '?7263, '?7264

Lifts a function into a Result container and applies it on the given result.

lift2 f a b
Signature: f:('?7274 -> '?7275 -> '?7276) -> a:Result<'?7274,'?7277> -> b:Result<'?7275,'?7277> -> Result<'?7276,'?7277>
Type parameters: '?7274, '?7275, '?7276, '?7277

Promote a function to a monad/applicative, scanning the monadic/applicative arguments from left to right.

mapFailure f result
Signature: f:('?7266 list -> '?7267 list) -> result:Result<'?7268,'?7266> -> Result<'?7268,'?7267>
Type parameters: '?7266, '?7267, '?7268

Maps a function over the existing error messages in case of failure. In case of success, the message type will be changed and warnings will be discarded.

mergeMessages msgs result
Signature: msgs:'?7240 list -> result:Result<'?7241,'?7240> -> Result<'?7241,'?7240>
Type parameters: '?7240, '?7241

Appends the given messages with the messages in the given result.

ofChoice choice
Signature: choice:Choice<'?7294,'?7295> -> Result<'?7294,'?7295>
Type parameters: '?7294, '?7295

Converts a Choice into a Result.

ok x
Signature: x:'TSuccess -> Result<'TSuccess,'TMessage>
Type parameters: 'TSuccess, 'TMessage

Wraps a value in a Success

pass x
Signature: x:'TSuccess -> Result<'TSuccess,'TMessage>
Type parameters: 'TSuccess, 'TMessage

Wraps a value in a Success

returnOrFail result
Signature: result:Result<'?7237,'?7238> -> '?7237
Type parameters: '?7237, '?7238

If the given result is a Success the wrapped value will be returned. Otherwise the function throws an exception with Failure message of the result.

successTee f result
Signature: f:('?7282 * '?7283 list -> unit) -> result:Result<'?7282,'?7283> -> Result<'?7282,'?7283>
Type parameters: '?7282, '?7283

If the result is a Success it executes the given function on the value and the messages. Result is propagated unchanged.

trial
Signature: TrialBuilder

Wraps computations in an error handling computation expression.

warn msg x
Signature: msg:'TMessage -> x:'TSuccess -> Result<'TSuccess,'TMessage>
Type parameters: 'TSuccess, 'TMessage

Wraps a value in a Success and adds a message

Active patterns

Active patternDescription
( |Pass|Warn|Fail| ) result
Signature: result:Result<'?7297,'?7298> -> Choice<'?7297,('?7297 * '?7298 list),'?7298 list>
Type parameters: '?7297, '?7298

Categorizes a result based on its state and the presence of extra messages

CompiledName: |Pass|Warn|Fail|

Fork me on GitHub