Class ReaderT<R,​M extends MonadRec<?,​M>,​A>

    • Constructor Detail

      • ReaderT

        private ReaderT​(Fn1<? super R,​? extends MonadRec<A,​M>> f)
    • Method Detail

      • runReaderT

        public <MA extends MonadRec<A,​M>> MA runReaderT​(R r)
        Run the computation represented by this ReaderT.
        Type Parameters:
        MA - the witnessed target type
        Parameters:
        r - the input
        Returns:
        the embedded MonadRec
      • mapReaderT

        public <MA extends MonadRec<A,​M>,​N extends MonadRec<?,​N>,​B> ReaderT<R,​N,​B> mapReaderT​(Fn1<? super MA,​? extends MonadRec<B,​N>> fn)
        Map the current monadic embedding to a new one in a potentially different Monad.
        Type Parameters:
        MA - the currently embedded Monad
        N - the new Monad witness
        B - the new carrier type
        Parameters:
        fn - the function
        Returns:
        the mapped ReaderT
      • and

        public <B> ReaderT<R,​M,​B> and​(ReaderT<A,​M,​B> amb)
        Left-to-right composition between ReaderT instances running under the same effect and compatible between their inputs and outputs.
        Type Parameters:
        B - the final output type
        Parameters:
        amb - the next ReaderT to run
        Returns:
        the composed ReaderT
      • local

        public ReaderT<R,​M,​A> local​(Fn1<? super R,​? extends R> fn)
        Modify this MonadReader's environment after reading it but before running the effect.
        Specified by:
        local in interface MonadReader<R,​M extends MonadRec<?,​M>,​A>
        Parameters:
        fn - the modification function
        Returns:
        the MonadReader with a modified environment
      • fmap

        public <B> ReaderT<R,​M,​B> fmap​(Fn1<? super A,​? extends B> fn)
        Covariantly transmute this functor's parameter using the given mapping function. Generally this method is specialized to return an instance of the class implementing Functor.
        Specified by:
        fmap in interface Applicative<R,​M extends MonadRec<?,​M>>
        Specified by:
        fmap in interface Functor<R,​M extends MonadRec<?,​M>>
        Specified by:
        fmap in interface Monad<R,​M extends MonadRec<?,​M>>
        Specified by:
        fmap in interface MonadReader<R,​M extends MonadRec<?,​M>,​A>
        Specified by:
        fmap in interface MonadRec<R,​M extends MonadRec<?,​M>>
        Specified by:
        fmap in interface MonadT<M extends MonadRec<?,​M>,​A,​ReaderT<R,​M extends MonadRec<?,​M>,​?>,​ReaderT<R,​?,​?>>
        Type Parameters:
        B - the new parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a functor over B (the new parameter type)
      • zip

        public <B> ReaderT<R,​M,​B> zip​(Applicative<Fn1<? super A,​? extends B>,​ReaderT<R,​M,​?>> appFn)
        Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.
        Specified by:
        zip in interface Applicative<R,​M extends MonadRec<?,​M>>
        Specified by:
        zip in interface Monad<R,​M extends MonadRec<?,​M>>
        Specified by:
        zip in interface MonadReader<R,​M extends MonadRec<?,​M>,​A>
        Specified by:
        zip in interface MonadRec<R,​M extends MonadRec<?,​M>>
        Specified by:
        zip in interface MonadT<M extends MonadRec<?,​M>,​A,​ReaderT<R,​M extends MonadRec<?,​M>,​?>,​ReaderT<R,​?,​?>>
        Type Parameters:
        B - the resulting applicative parameter type
        Parameters:
        appFn - the other applicative instance
        Returns:
        the mapped applicative
      • diMap

        public <Q,​B> ReaderT<Q,​M,​B> diMap​(Fn1<? super Q,​? extends R> lFn,
                                                            Fn1<? super A,​? extends B> rFn)
        Dually map contravariantly over the left parameter and covariantly over the right parameter. This is isomorphic to diMapL(lFn).diMapR(rFn).
        Specified by:
        diMap in interface Cartesian<R,​M extends MonadRec<?,​M>,​A>
        Specified by:
        diMap in interface Profunctor<R,​M extends MonadRec<?,​M>,​A>
        Type Parameters:
        Q - the new left parameter type
        B - the new right parameter type
        Parameters:
        lFn - the left parameter mapping function
        rFn - the right parameter mapping function
        Returns:
        a profunctor over Z (the new left parameter type) and C (the new right parameter type)
      • diMapL

        public <Q> ReaderT<Q,​M,​A> diMapL​(Fn1<? super Q,​? extends R> fn)
        Contravariantly map over the left parameter.
        Specified by:
        diMapL in interface Cartesian<R,​M extends MonadRec<?,​M>,​A>
        Specified by:
        diMapL in interface Profunctor<R,​M extends MonadRec<?,​M>,​A>
        Type Parameters:
        Q - the new left parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a profunctor over Z (the new left parameter type) and C (the same right parameter type)
      • diMapR

        public <B> ReaderT<R,​M,​B> diMapR​(Fn1<? super A,​? extends B> fn)
        Covariantly map over the right parameter. For all profunctors that are also functors, it should hold that diMapR(f) == fmap(f).
        Specified by:
        diMapR in interface Cartesian<R,​M extends MonadRec<?,​M>,​A>
        Specified by:
        diMapR in interface Profunctor<R,​M extends MonadRec<?,​M>,​A>
        Type Parameters:
        B - the new right parameter type
        Parameters:
        fn - the mapping function
        Returns:
        a profunctor over A (the same left parameter type) and C (the new right parameter type)
      • cartesian

        public <C> ReaderT<Tuple2<C,​R>,​M,​Tuple2<C,​A>> cartesian()
        Pair some type C to this profunctor's carrier types.
        Specified by:
        cartesian in interface Cartesian<R,​M extends MonadRec<?,​M>,​A>
        Type Parameters:
        C - the paired type
        Returns:
        the cartesian-strengthened profunctor
      • carry

        public ReaderT<R,​M,​Tuple2<R,​A>> carry()
        Pair the covariantly-positioned carrier type with the contravariantly-positioned carrier type. This can be thought of as "carrying" or "inspecting" the left parameter.
        Specified by:
        carry in interface Cartesian<R,​M extends MonadRec<?,​M>,​A>
        Returns:
        the profunctor with the first parameter carried
      • ask

        public static <R,​M extends MonadRec<?,​M>> ReaderT<R,​M,​R> ask​(Pure<M> pureM)
        Given a Pure ask will give you access to the input within the monadic embedding
        Type Parameters:
        R - the input and output type of the returned ReaderT
        M - the returned Monad
        Parameters:
        pureM - the Pure instance for the given Monad
        Returns:
        the ReaderT
      • readerT

        public static <R,​M extends MonadRec<?,​M>,​A> ReaderT<R,​M,​A> readerT​(Fn1<? super R,​? extends MonadRec<A,​M>> fn)
        Lift a function (R -> Monad<A, M>) into a ReaderT instance.
        Type Parameters:
        R - the input type
        M - the returned Monad
        A - the embedded output type
        Parameters:
        fn - the function
        Returns:
        the ReaderT
      • pureReaderT

        public static <R,​M extends MonadRec<?,​M>> Pure<ReaderT<R,​M,​?>> pureReaderT​(Pure<M> pureM)
        The canonical Pure instance for ReaderT.
        Type Parameters:
        R - the input type
        M - the argument Monad witness
        Parameters:
        pureM - the argument Monad Pure
        Returns:
        the Pure instance
      • liftReaderT

        public static <R> Lift<ReaderT<R,​?,​?>> liftReaderT()
        Type Parameters:
        R - the environment type
        Returns:
        the Monad lifted into ReaderT