Class AutoBracket<A extends java.lang.AutoCloseable,​B>

  • Type Parameters:
    A - the initial AutoCloseable value type to map and clean up
    B - the resulting type
    All Implemented Interfaces:
    Fn1<IO<A>,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>>, Fn2<IO<A>,​Fn1<? super A,​? extends IO<B>>,​IO<B>>, Applicative<Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<IO<A>,​?>>, Cartesian<IO<A>,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<?,​?>>, Cocartesian<IO<A>,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<?,​?>>, Contravariant<IO<A>,​Profunctor<?,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<?,​?>>>, Functor<Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<IO<A>,​?>>, Profunctor<IO<A>,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<?,​?>>, Monad<Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<IO<A>,​?>>, MonadReader<IO<A>,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<IO<A>,​?>>, MonadRec<Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<IO<A>,​?>>, MonadWriter<IO<A>,​Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>>,​Fn1<IO<A>,​?>>

    public final class AutoBracket<A extends java.lang.AutoCloseable,​B>
    extends java.lang.Object
    implements Fn2<IO<A>,​Fn1<? super A,​? extends IO<B>>,​IO<B>>
    Given an IO yielding some AutoCloseable type A and a kleisli arrow from that type to a new IO of type B, attempt to provision the A, applying the body operation if provisioning was successful and ensuring that AutoCloseable.close() is called regardless of whether the body succeeds or fails.

    This is the canonical bracketing operation for AutoCloseables.

    See Also:
    Bracket
    • Field Detail

      • INSTANCE

        private static final AutoBracket<?,​?> INSTANCE
    • Constructor Detail

      • AutoBracket

        private AutoBracket()
    • Method Detail

      • checkedApply

        public IO<B> checkedApply​(IO<A> io,
                                  Fn1<? super A,​? extends IO<B>> bodyIO)
        Specified by:
        checkedApply in interface Fn2<IO<A extends java.lang.AutoCloseable>,​Fn1<? super A extends java.lang.AutoCloseable,​? extends IO<B>>,​IO<B>>
      • autoBracket

        public static <A extends java.lang.AutoCloseable,​B> AutoBracket<A,​B> autoBracket()
      • autoBracket

        public static <A extends java.lang.AutoCloseable,​B> Fn1<Fn1<? super A,​? extends IO<B>>,​IO<B>> autoBracket​(IO<A> io)
      • autoBracket

        public static <A extends java.lang.AutoCloseable,​B> IO<B> autoBracket​(IO<A> io,
                                                                                    Fn1<? super A,​? extends IO<B>> bodyIO)