Result
Type of results that are either a successful value or an error value, and its functions.
case Ok(t)case Err(e)Type of results that are either a successful value or an error value.
The constructor Ok(v) represents the successful value v,
whereas the constructor Err(v) represents the error value v.
Instances
Applicative, Eq, Formattable, Functor, Hash, Monad, Order, ToString
Definitions
Applies the function in r1 to the value in r2.
Returns 1 if r is Ok(v) and the predicate f(v) evaluates to true. Otherwise returns 0.
Returns true if r is Ok(v) and the predicate f(v) evaluates to true. Otherwise returns false.
Returns Some(v) if r is Ok(v) and the predicate f(v) evaluates to true. Otherwise returns None.
The function f must be pure.
Returns f(v) if r is Ok(v). Returns Err(w) if r is Err(w).
Returns v if r is Ok(v). Returns Err(w) if r is Err(w).
Returns f(z, v) if r is Ok(v). Otherwise returns z.
Returns the result of applying f to a start value s and the elements in l
going from left to right.
If at any step applying f fails (i.e. it produces a Err(e) value) the traversal
of l is short-circuited and Err(e) is returned.
If f is successfully applied to all elements in l the result is of the form:
Ok(f(...f(f(s, x1), x2)..., xn)).
Returns f(v, z) if r is Ok(v). Otherwise returns z.
Returns the result of applying f to a start value s and the elements in l
going from right to left.
If at any step applying f fails (i.e. it produces a Err(e) value) the traversal
of l is short-circuited and Err(e) is returned.
If f is successfully applied to all elements in l the result is of the form:
Ok(f(x1, ...f(xn-1, f(xn, s))...)).
Returns true if r is Ok(v) and the predicate f(v) evaluates to true or if r is Err(w).
Otherwise returns false.
Applies f to v if r is Ok(v). Otherwise does nothing.
Returns v if r is Ok(v). Otherwise aborts with a stack trace.
Returns an iterator over r with 1 element or an empty iterator if r is Err.
Returns Ok(f(v)) if r is Ok(v). Returns Err(w) if r is Err(w).
def map10(f: t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> (t8 -> (t9 -> (t10 -> u \ ef))))))))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4], r5: Result[e, t5], r6: Result[e, t6], r7: Result[e, t7], r8: Result[e, t8], r9: Result[e, t9], r10: Result[e, t10]): Result[e, u] \ ef§ SourceApplies the 10-ary function f to the values in r1, r2, ... r10.
Returns the first Err(e) value if any of r1, r2, ... r10 are Err(e).
Applies the binary function f to the values in r1 and r2.
Returns the first Err(e) value if either of r1 and r2 are Err(e).
def map3(f: t1 -> (t2 -> (t3 -> u \ ef)), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3]): Result[e, u] \ ef§ SourceApplies the ternary function f to the values in r1, r2 and r3.
Returns the first Err(e) value if any of r1, r2 and r3 are Err(e).
def map4(f: t1 -> (t2 -> (t3 -> (t4 -> u \ ef))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4]): Result[e, u] \ ef§ SourceApplies the 4-ary function f to the values in r1, r2, r3 and r4.
Returns the first Err(e) value if any of r1, r2, r3 and r4 are Err(e).
def map5(f: t1 -> (t2 -> (t3 -> (t4 -> (t5 -> u \ ef)))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4], r5: Result[e, t5]): Result[e, u] \ ef§ SourceApplies the 5-ary function f to the values in r1, r2, ... r5.
Returns the first Err(e) value if any of r1, r2, ... r5 are Err(e).
def map6(f: t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> u \ ef))))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4], r5: Result[e, t5], r6: Result[e, t6]): Result[e, u] \ ef§ SourceApplies the 6-ary function f to the values in r1, r2, ... r6.
Returns the first Err(e) value if any of r1, r2, ... r6 are Err(e).
def map7(f: t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> u \ ef)))))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4], r5: Result[e, t5], r6: Result[e, t6], r7: Result[e, t7]): Result[e, u] \ ef§ SourceApplies the 7-ary function f to the values in r1, r2, ... r7.
Returns the first Err(e) value if any of r1, r2, ... r7 are Err(e).
def map8(f: t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> (t8 -> u \ ef))))))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4], r5: Result[e, t5], r6: Result[e, t6], r7: Result[e, t7], r8: Result[e, t8]): Result[e, u] \ ef§ SourceApplies the 8-ary function f to the values in r1, r2, ... r8.
Returns the first Err(e) value if any of r1, r2, ... r8 are Err(e).
def map9(f: t1 -> (t2 -> (t3 -> (t4 -> (t5 -> (t6 -> (t7 -> (t8 -> (t9 -> u \ ef)))))))), r1: Result[e, t1], r2: Result[e, t2], r3: Result[e, t3], r4: Result[e, t4], r5: Result[e, t5], r6: Result[e, t6], r7: Result[e, t7], r8: Result[e, t8], r9: Result[e, t9]): Result[e, u] \ ef§ SourceApplies the 9-ary function f to the values in r1, r2, ... r9.
Returns the first Err(e) value if any of r1, r2, ... r9 are Err(e).
Returns Err(f(e)) if r is Err(e). Returns Ok(v) if r is Ok(v).
Returns Ok(dst) if r is Ok(src). Otherwise returns r.
Returns Ok(v1 :: v2 :: ... :: vn) if each of l_i is Ok(v_i).
Otherwise returns the first Err encountered.
Returns f(v) if r is Ok(v) else 0.
Returns a one-element list of the value v if r is Ok(v). Otherwise returns the empty list.
Returns a singleton map with the mapping k -> v if r is Ok((k, v)). Otherwise returns the empty map.
Returns a map with elements of s as keys and f applied as values.
Returns Some(v) if r is Ok(v). Otherwise returns None.
Returns a one-element set of the value v if r is Ok(v). Otherwise returns the empty set.
Returns a Success(v) if r is Ok(v). Otherwise returns a
Failure(Nec.singleton(t)) if r is Err(t).
Returns Ok(v1 :: v2 :: ... v :: vn) if each of f(l_i) is Ok(v_i).
Otherwise returns the first Err encountered.
Returns Ok() if each of f(l_i) is Ok(_). Otherwise returns the first Err.
This function is the "forgetful" version of traverse, use it when you want the effect
of applying f to each element but do not care about collecting the results.