/** * Collects the first element of the `Collection( as: Collection, f: (a: A) => STM> ): STM> { return STM.suspend(loop(as[Symbol.iterator](), f)) } function loop( iterator: Iterator, f: (a: A) => STM> ): STM> { const next = iterator.next() return next.done ? STM.none : f(next.value).flatMap((option) => option.fold(loop(iterator, f), STM.some)) }