Interface Effect<A>

Type Parameters:
A - the argument type
All Superinterfaces:
Applicative<IO<Unit>,Fn1<A,?>>, Cartesian<A,IO<Unit>,Fn1<?,?>>, Cocartesian<A,IO<Unit>,Fn1<?,?>>, Contravariant<A,Profunctor<?,IO<Unit>,Fn1<?,?>>>, Fn1<A,IO<Unit>>, Functor<IO<Unit>,Fn1<A,?>>, Monad<IO<Unit>,Fn1<A,?>>, MonadReader<A,IO<Unit>,Fn1<A,?>>, MonadRec<IO<Unit>,Fn1<A,?>>, MonadWriter<A,IO<Unit>,Fn1<A,?>>, Profunctor<A,IO<Unit>,Fn1<?,?>>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Effect<A> extends Fn1<A,IO<Unit>>
A function returning "no result", and therefore only useful as a side-effect.
See Also:
  • Method Details

    • checkedApply

      IO<Unit> checkedApply(A a) throws Throwable
      Description copied from interface: Fn1
      Invoke this function with the given argument, potentially throwing any Throwable.
      Specified by:
      checkedApply in interface Fn1<A,IO<Unit>>
      Parameters:
      a - the argument
      Returns:
      the result of the function application
      Throws:
      Throwable - anything possibly thrown by the function
    • toConsumer

      default Consumer<A> toConsumer()
      Convert this Effect to a java Consumer
      Returns:
      the Consumer
    • apply

      default IO<Unit> apply(A a)
      Invoke this function explosively with the given argument.
      Specified by:
      apply in interface Fn1<A,IO<Unit>>
      Parameters:
      a - the argument
      Returns:
      the result of the function application
    • andThen

      default Effect<A> andThen(Effect<A> effect)
      Left-to-right composition of Effects.
      Parameters:
      effect - the other Effect
      Returns:
      the composed Effect
    • diMapL

      default <Z> Effect<Z> diMapL(Fn1<? super Z,? extends A> fn)
      Contravariantly map over the argument to this function, producing a function that takes the new argument type, and produces the same result.
      Specified by:
      diMapL in interface Cartesian<A,IO<Unit>,Fn1<?,?>>
      Specified by:
      diMapL in interface Cocartesian<A,IO<Unit>,Fn1<?,?>>
      Specified by:
      diMapL in interface Fn1<A,IO<Unit>>
      Specified by:
      diMapL in interface Profunctor<A,IO<Unit>,Fn1<?,?>>
      Type Parameters:
      Z - the new argument type
      Parameters:
      fn - the contravariant argument mapping function
      Returns:
      an Fn1<Z, B>
    • contraMap

      default <Z> Effect<Z> contraMap(Fn1<? super Z,? extends A> fn)
      Contravariantly map A <- B.
      Specified by:
      contraMap in interface Cartesian<A,IO<Unit>,Fn1<?,?>>
      Specified by:
      contraMap in interface Cocartesian<A,IO<Unit>,Fn1<?,?>>
      Specified by:
      contraMap in interface Contravariant<A,Profunctor<?,IO<Unit>,Fn1<?,?>>>
      Specified by:
      contraMap in interface Fn1<A,IO<Unit>>
      Specified by:
      contraMap in interface Profunctor<A,IO<Unit>,Fn1<?,?>>
      Type Parameters:
      Z - the new parameter type
      Parameters:
      fn - the mapping function
      Returns:
      the mapped Contravariant functor instance
    • discardR

      default <C> Effect<A> discardR(Applicative<C,Fn1<A,?>> appB)
      Sequence both this Applicative and appB, discarding appB's result and returning this Applicative. This is generally useful for sequentially performing side-effects.
      Specified by:
      discardR in interface Applicative<IO<Unit>,Fn1<A,?>>
      Specified by:
      discardR in interface Fn1<A,IO<Unit>>
      Specified by:
      discardR in interface Monad<IO<Unit>,Fn1<A,?>>
      Specified by:
      discardR in interface MonadReader<A,IO<Unit>,Fn1<A,?>>
      Specified by:
      discardR in interface MonadRec<IO<Unit>,Fn1<A,?>>
      Specified by:
      discardR in interface MonadWriter<A,IO<Unit>,Fn1<A,?>>
      Type Parameters:
      C - the type of appB's parameter
      Parameters:
      appB - the other Applicative
      Returns:
      this Applicative
    • fromConsumer

      static <A> Effect<A> fromConsumer(Consumer<A> consumer)
      Static factory method to create an Effect from a java Consumer.
      Type Parameters:
      A - the input type
      Parameters:
      consumer - the Consumer
      Returns:
      the Effect
    • effect

      static <A> Effect<A> effect(SideEffect sideEffect)
      Create an Effect from a SideEffect;
      Type Parameters:
      A - any desired input type
      Parameters:
      sideEffect - the SideEffect
      Returns:
      the Effect
    • noop

      static <A> Effect<A> noop()
      Create an Effect that accepts an input and does nothing;
      Type Parameters:
      A - any desired input type
      Returns:
      the noop Effect
    • effect

      static <A> Effect<A> effect(Fn1<? super A,? extends IO<?>> fn)
      Create an Effect from an Fn1 that yields an IO.
      Type Parameters:
      A - the effect argument type
      Parameters:
      fn - the function
      Returns:
      the effect