Requires an implementation of Tuple.
Must include the following:
- A
Try type.
- The following static constructors:
- The following static methods:
attempt :: (() -> a) → Try a: Wraps a successful execution in a Successand a thrownExeptionin aFailure`.
failures :: [Try a b] → [a]: Extracts from a list of Try all of the Failure elements in extracted order.
fromFailure :: a → Try a b → a: Extracts the value of a Failure; otherwise, returns the defaultValue.
fromSuccess :: b → Try a b → b: Extracts the value of a Success; otherwise, returns the defaultValue.
isFailure :: Try a b → Boolean: Determines whether or not the argument is a Failure.
isSuccess :: Try a b → Boolean: Determines whether or not the argument is a Success.
partitionTries :: [Try a b] → ([a], [b]): Partitions a list of Try into two lists. All Failure elements are extracted, in order, to the first position of the output. Similarly for the Success elements in the second position.
successes :: [Try a b] → [b]: Extracts from a list of Try all of the Success elements in extracted order.
tryMap :: ([a] → c) → (b → c) → Try a b → c: If the value is Failure a, apply the first function to [a]; otherwise, apply the second function to b.
Requires an implementation of
Tuple.Must include the following:
Trytype.failure asuccess battempt :: (() -> a) → Try a: Wraps a successful execution in aSuccessand a thrownExeptionin aFailure`.failures :: [Try a b] → [a]: Extracts from a list ofTryall of theFailureelements in extracted order.fromFailure :: a → Try a b → a: Extracts the value of aFailure; otherwise, returns thedefaultValue.fromSuccess :: b → Try a b → b: Extracts the value of aSuccess; otherwise, returns thedefaultValue.isFailure :: Try a b → Boolean: Determines whether or not the argument is aFailure.isSuccess :: Try a b → Boolean: Determines whether or not the argument is aSuccess.partitionTries :: [Try a b] → ([a], [b]): Partitions a list ofTryinto two lists. AllFailureelements are extracted, in order, to the first position of the output. Similarly for theSuccesselements in the second position.successes :: [Try a b] → [b]: Extracts from a list ofTryall of theSuccesselements in extracted order.tryMap :: ([a] → c) → (b → c) → Try a b → c: If the value isFailure a, apply the first function to[a]; otherwise, apply the second function tob.