diff --git a/src/infiniyield.gleam b/src/infiniyield.gleam index a49b0e3..ca55563 100644 --- a/src/infiniyield.gleam +++ b/src/infiniyield.gleam @@ -7,7 +7,7 @@ type Action(element) { /// An yielder is a lazily evaluated infinite sequence of elements. /// -/// As a lazy data structure no work is done when an yielder is filtered, +/// As a lazy data structure no work is done when a yielder is filtered, /// mapped, etc, instead a new yielder is returned with these transformations /// applied to the stream. Once the stream has all the required transformations /// applied it can be evaluated using functions such as `take` and `step`. @@ -21,7 +21,7 @@ pub type Step(element, accumulator) { Next(element: element, accumulator: accumulator) } -/// Creates an yielder from a given function and accumulator. +/// Creates a yielder from a given function and accumulator. /// /// The function is called on the accumulator and returns `Next` which contains a /// new element and accumulator. The element is yielded by the yielder and the @@ -59,7 +59,7 @@ fn unfold_loop( } } -/// Creates an yielder that yields values created by calling a given function +/// Creates a yielder that yields values created by calling a given function /// repeatedly. /// /// ```gleam @@ -72,7 +72,7 @@ pub fn repeatedly(f: fn() -> element) -> Yielder(element) { unfold(Nil, fn(_) { Next(f(), Nil) }) } -/// Creates an yielder that returns the same value infinitely. +/// Creates a yielder that returns the same value infinitely. /// /// ## Examples /// @@ -86,7 +86,7 @@ pub fn repeat(x: element) -> Yielder(element) { repeatedly(fn() { x }) } -/// Creates an yielder from an existing yielder +/// Creates a yielder from an existing yielder /// and a stateful function that may short-circuit. /// /// `f` takes arguments `acc` for current state and `el` for current element from underlying yielder, @@ -124,7 +124,7 @@ fn transform_loop( } } -/// Eagerly accesses the first value of an yielder, returning a `Next` +/// Eagerly accesses the first value of a yielder, returning a `Next` /// that contains the first value and the rest of the yielder. /// /// ## Examples @@ -179,7 +179,7 @@ fn take_loop( } } -/// Evaluates and discards the first N elements in an yielder, returning a new +/// Evaluates and discards the first N elements in a yielder, returning a new /// yielder. /// /// This function does not evaluate the elements of the yielder, the @@ -207,7 +207,7 @@ fn drop_loop(continuation: fn() -> Action(e), desired: Int) -> Action(e) { } } -/// Creates an yielder from an existing yielder and a transformation function. +/// Creates a yielder from an existing yielder and a transformation function. /// /// Each element in the new yielder will be the result of calling the given /// function on the elements in the given yielder. @@ -239,7 +239,7 @@ fn map_loop(continuation: fn() -> Action(a), f: fn(a) -> b) -> fn() -> Action(b) /// Combines two yielders into a single one using the given function. /// -/// If an yielder is longer than the other the extra elements are dropped. +/// If a yielder is longer than the other the extra elements are dropped. /// /// This function does not evaluate the elements of the two yielders, the /// computation is performed when the resulting yielder is later run. @@ -281,7 +281,7 @@ fn map2_loop( } } -/// Creates an yielder from an existing yielder and a predicate function. +/// Creates a yielder from an existing yielder and a predicate function. /// /// The new yielder will contain elements from the first yielder for which /// the given function returns `True`. @@ -319,7 +319,7 @@ fn filter_loop( } } -/// Creates an yielder from an existing yielder and a transforming predicate function. +/// Creates a yielder from an existing yielder and a transforming predicate function. /// /// The new yielder will contain elements from the first yielder for which /// the given function returns `Ok`, transformed to the value inside the `Ok`. @@ -360,7 +360,7 @@ fn filter_map_loop( } } -/// Creates an yielder that repeats a given list infinitely. +/// Creates a yielder that repeats a given list infinitely. /// /// If an empty list is provided, attempting to yield a value /// from the yielder will result in an infinite loop. @@ -383,7 +383,7 @@ fn cycle_loop(list: List(a), cur: List(a)) -> Action(a) { } } -/// Creates an yielder of ints, starting at a given start int +/// Creates a yielder of ints, starting at a given start int /// and incrementing by one each time. /// /// ## Examples @@ -397,7 +397,7 @@ pub fn incrementing(from start: Int) -> Yielder(Int) { unfold(from: start, with: fn(current) { Next(current, current + 1) }) } -/// Creates an yielder of ints, starting at a given start int +/// Creates a yielder of ints, starting at a given start int /// and decrementing by one each time. /// /// ## Examples @@ -461,7 +461,7 @@ fn find_map_loop(continuation: fn() -> Action(a), f: fn(a) -> Result(b, c)) -> b } } -/// Wraps values yielded from an yielder with indices, starting from 0. +/// Wraps values yielded from a yielder with indices, starting from 0. /// /// ## Examples /// @@ -486,7 +486,7 @@ fn index_loop( } } -/// Creates an yielder that infinitely applies a function to a value. +/// Creates a yielder that infinitely applies a function to a value. /// /// ## Examples /// @@ -502,7 +502,7 @@ pub fn iterate( unfold(initial, fn(element) { Next(element, f(element)) }) } -/// Creates an yielder that yields elements while the predicate returns `True`. +/// Creates a list containing the elements while the predicate returns `True`. /// /// ## Examples /// @@ -533,7 +533,7 @@ fn take_while_loop( } } -/// Creates an yielder that drops elements while the predicate returns `True`, +/// Creates a yielder that drops elements while the predicate returns `True`, /// and then yields the remaining elements. /// /// ## Examples @@ -564,7 +564,7 @@ fn drop_while_loop( } } -/// Creates an yielder from an existing yielder and a stateful function. +/// Creates a yielder from an existing yielder and a stateful function. /// /// Specifically, this behaves like `fold`, but yields intermediate results. /// @@ -633,7 +633,7 @@ type Chunk(element, key) { AnotherBy(List(element), key, element, fn() -> Action(element)) } -/// Creates an yielder that emits chunks of elements +/// Creates a yielder that emits chunks of elements /// for which `f` returns the same value. /// /// ## Examples @@ -681,7 +681,7 @@ fn next_chunk( } } -/// Creates an yielder that emits chunks of given size. +/// Creates a yielder that emits chunks of given size. /// /// If the last chunk does not have `count` elements, it is yielded /// as a partial chunk, with less than `count` elements. @@ -741,7 +741,7 @@ fn next_sized_chunk( } } -/// Creates an yielder that yields the given `elem` element +/// Creates a yielder that yields the given `elem` element /// between elements emitted by the underlying yielder. /// /// ## Examples @@ -780,7 +780,7 @@ fn intersperse_loop( Continue(separator, fn() { Continue(e, next_interspersed) }) } -/// Creates an yielder that alternates between the two given yielders. +/// Creates a yielder that alternates between the two given yielders. /// /// ## Examples /// @@ -915,7 +915,7 @@ pub fn each(over yielder: Yielder(a), with f: fn(a) -> b) -> Yielder(Nil) { }) } -/// Add a new element to the start of an yielder. +/// Add a new element to the start of a yielder. /// /// This function is for use with `use` expressions, to replicate the behaviour /// of the `yield` keyword found in other languages. @@ -941,7 +941,7 @@ pub fn yield(element: a, next: fn() -> Yielder(a)) -> Yielder(a) { Yielder(fn() { Continue(element, fn() { next().continuation() }) }) } -/// Add a new element to the start of an yielder. +/// Add a new element to the start of a yielder. /// /// ## Examples ///