@Test public void bracketError() { UIO<String> bracket = UIO.bracket(openError(), getString("id")); assertThrows(SQLException.class, bracket::unsafeRunSync); }
public static <A extends AutoCloseable, B> UIO<B> bracket( UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use) { return fold(ZIO.bracket(ZIO.redeem(acquire.instance), resource -> ZIO.redeem(use.andThen(UIOOf::narrowK).apply(resource).instance))); }
UIO implements UIOOf<A>, Recoverable { public static <A extends AutoCloseable, B> UIO<B> bracket( UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use) { return fold(ZIO.bracket(ZIO.redeem(acquire.instance), resource -> ZIO.redeem(use.andThen(UIOOf::narrowK).apply(resource).instance))); } }
UIO implements UIOOf<A>, Recoverable { public static <A extends AutoCloseable, B> UIO<B> bracket( UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use) { return fold(ZIO.bracket(ZIO.redeem(acquire.instance), resource -> ZIO.redeem(use.andThen(UIOOf::narrowK).apply(resource).instance))); } UIO(ZIO<Nothing, Nothing, A> value); }
UIO implements UIOOf<A>, Recoverable { public static <A extends AutoCloseable, B> UIO<B> bracket( UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use) { return fold(ZIO.bracket(ZIO.redeem(acquire.instance), resource -> ZIO.redeem(use.andThen(UIOOf::narrowK).apply(resource).instance))); } UIO(ZIO<Nothing, Nothing, A> value); A unsafeRunSync(); Try<A> safeRunSync(); @SuppressWarnings("unchecked") ZIO<R, E, A> toZIO(); @SuppressWarnings("unchecked") EIO<E, A> toEIO(); @SuppressWarnings("unchecked") RIO<R, A> toRIO(); @SuppressWarnings("unchecked") URIO<R, A> toURIO(); Task<A> toTask(); Future<A> toFuture(); Future<A> toFuture(Executor executor); void safeRunAsync(Executor executor, Consumer1<? super Try<? extends A>> callback); void safeRunAsync(Consumer1<? super Try<? extends A>> callback); Kind<F, A> foldMap(Async<F> monad); UIO<B> map(Function1<? super A, ? extends B> map); UIO<B> flatMap(Function1<? super A, ? extends UIO<? extends B>> map); UIO<B> andThen(UIO<? extends B> next); UIO<B> ap(UIO<Function1<? super A, ? extends B>> apply); UIO<A> recover(Function1<? super Throwable, ? extends A> mapError); @SuppressWarnings("unchecked") UIO<A> recoverWith(Class<X> type, Function1<? super X, ? extends A> function); UIO<B> redeem(
      Function1<? super Throwable, ? extends B> mapError, Function1<? super A, ? extends B> map); UIO<B> redeemWith(
      Function1<? super Throwable, ? extends UIO<? extends B>> mapError, 
      Function1<? super A, ? extends UIO<? extends B>> map); UIO<Tuple2<A, B>> zip(UIO<? extends B> other); UIO<A> zipLeft(UIO<? extends B> other); UIO<B> zipRight(UIO<? extends B> other); UIO<C> zipWith(UIO<? extends B> other, 
      Function2<? super A, ? super B, ? extends C> mapper); UIO<A> repeat(); UIO<A> repeat(int times); UIO<A> repeat(Duration delay); UIO<A> repeat(Duration delay, int times); UIO<B> repeat(Schedule<Nothing, A, B> schedule); UIO<A> retry(); UIO<A> retry(int maxRetries); UIO<A> retry(Duration delay); UIO<A> retry(Duration delay, int maxRetries); UIO<A> retry(Schedule<Nothing, Throwable, B> schedule); UIO<Tuple2<Duration, A>> timed(); static UIO<C> map2(UIO<? extends A> za, UIO<? extends B> zb, 
      Function2<? super A, ? super B, ? extends C> mapper); static Function1<A, UIO<B>> lift(Function1<? super A, ? extends B> function); static UIO<Unit> sleep(Duration delay); static UIO<Unit> exec(CheckedRunnable task); static UIO<A> pure(A value); static UIO<A> raiseError(Throwable throwable); static UIO<A> defer(Producer<UIO<? extends A>> lazy); static UIO<A> task(Producer<? extends A> task); static UIO<A> async(Consumer1<Consumer1<? super Try<? extends A>>> consumer); static UIO<A> asyncF(Function1<Consumer1<? super Try<? extends A>>, UIO<Unit>> consumer); static UIO<B> bracket(
      UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use); static UIO<B> bracket(UIO<? extends A> acquire, 
      Function1<? super A, ? extends UIO<? extends B>> use, Consumer1<? super A> release); static UIO<Unit> unit(); }
UIO implements UIOOf<A>, Recoverable { public static <A extends AutoCloseable, B> UIO<B> bracket( UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use) { return fold(ZIO.bracket(ZIO.redeem(acquire.instance), resource -> ZIO.redeem(use.andThen(UIOOf::narrowK).apply(resource).instance))); } UIO(ZIO<Nothing, Nothing, A> value); A unsafeRunSync(); Try<A> safeRunSync(); @SuppressWarnings("unchecked") ZIO<R, E, A> toZIO(); @SuppressWarnings("unchecked") EIO<E, A> toEIO(); @SuppressWarnings("unchecked") RIO<R, A> toRIO(); @SuppressWarnings("unchecked") URIO<R, A> toURIO(); Task<A> toTask(); Future<A> toFuture(); Future<A> toFuture(Executor executor); void safeRunAsync(Executor executor, Consumer1<? super Try<? extends A>> callback); void safeRunAsync(Consumer1<? super Try<? extends A>> callback); Kind<F, A> foldMap(Async<F> monad); UIO<B> map(Function1<? super A, ? extends B> map); UIO<B> flatMap(Function1<? super A, ? extends UIO<? extends B>> map); UIO<B> andThen(UIO<? extends B> next); UIO<B> ap(UIO<Function1<? super A, ? extends B>> apply); UIO<A> recover(Function1<? super Throwable, ? extends A> mapError); @SuppressWarnings("unchecked") UIO<A> recoverWith(Class<X> type, Function1<? super X, ? extends A> function); UIO<B> redeem(
      Function1<? super Throwable, ? extends B> mapError, Function1<? super A, ? extends B> map); UIO<B> redeemWith(
      Function1<? super Throwable, ? extends UIO<? extends B>> mapError, 
      Function1<? super A, ? extends UIO<? extends B>> map); UIO<Tuple2<A, B>> zip(UIO<? extends B> other); UIO<A> zipLeft(UIO<? extends B> other); UIO<B> zipRight(UIO<? extends B> other); UIO<C> zipWith(UIO<? extends B> other, 
      Function2<? super A, ? super B, ? extends C> mapper); UIO<A> repeat(); UIO<A> repeat(int times); UIO<A> repeat(Duration delay); UIO<A> repeat(Duration delay, int times); UIO<B> repeat(Schedule<Nothing, A, B> schedule); UIO<A> retry(); UIO<A> retry(int maxRetries); UIO<A> retry(Duration delay); UIO<A> retry(Duration delay, int maxRetries); UIO<A> retry(Schedule<Nothing, Throwable, B> schedule); UIO<Tuple2<Duration, A>> timed(); static UIO<C> map2(UIO<? extends A> za, UIO<? extends B> zb, 
      Function2<? super A, ? super B, ? extends C> mapper); static Function1<A, UIO<B>> lift(Function1<? super A, ? extends B> function); static UIO<Unit> sleep(Duration delay); static UIO<Unit> exec(CheckedRunnable task); static UIO<A> pure(A value); static UIO<A> raiseError(Throwable throwable); static UIO<A> defer(Producer<UIO<? extends A>> lazy); static UIO<A> task(Producer<? extends A> task); static UIO<A> async(Consumer1<Consumer1<? super Try<? extends A>>> consumer); static UIO<A> asyncF(Function1<Consumer1<? super Try<? extends A>>, UIO<Unit>> consumer); static UIO<B> bracket(
      UIO<? extends A> acquire, Function1<? super A, ? extends UIO<? extends B>> use); static UIO<B> bracket(UIO<? extends A> acquire, 
      Function1<? super A, ? extends UIO<? extends B>> use, Consumer1<? super A> release); static UIO<Unit> unit();  }