diff --git a/emis_funky_funktions.py b/emis_funky_funktions.py index 54a1706..1fec916 100644 --- a/emis_funky_funktions.py +++ b/emis_funky_funktions.py @@ -707,7 +707,7 @@ def unwrap_r(r: Result[A, Any]) -> A: return val case Err(e): raise AssertionError(f'Tried to unwrap an error: ', e) -def sequence(s: Sequence[Result[A, B]]) -> Result[Iterator[A], B]: +def sequence(s: Sequence[Result[A, B]]) -> Result[Sequence[A], B]: """ Convert a list of results into a result of a list. @@ -716,14 +716,14 @@ def sequence(s: Sequence[Result[A, B]]) -> Result[Iterator[A], B]: errors, proccessing of the sequence is immediately stopped, and the first error encountered is returned. - >>> map_res(list, sequence([Ok(1), Ok(2), Ok(3)])) + >>> sequence([Ok(1), Ok(2), Ok(3)]) Ok([1, 2, 3]) >>> sequence([Ok(1), Err('Oops!'), Err('Aw man!')]) Err('Oops!') """ if all(s): - return Ok(map(unwrap_r, s)) + return Ok(list(map(unwrap_r, s))) else: o = next(filter(not_, s)) assert isinstance(o, Err)