/**
* Drops elements from the queue while they do not satisfy the predicate,
* taking and returning the first element that does satisfy the predicate.
* Retries if no elements satisfy the predicate.
*
* @tsplus static effect/core/stm/TQueue.Aspects seek
* @tsplus pipeable effect/core/stm/TQueue seek
*/
export function seek(f: (a: A) => boolean) {
return (self: TQueue): STM =>
self.take.flatMap(
(b) => f(b) ? STM.succeed(b) : self.seek(f)
)
}