Class LambdaIterable<A>

    • Field Detail

      • as

        private final java.lang.Iterable<A> as
    • Constructor Detail

      • LambdaIterable

        private LambdaIterable​(java.lang.Iterable<? extends A> as)
    • Method Detail

      • unwrap

        public java.lang.Iterable<A> unwrap()
        Unwrap the underlying Iterable.
        Returns:
        the wrapped Iterable
      • zip

        public <B> LambdaIterable<B> zip​(Applicative<Fn1<? super A,​? extends B>,​LambdaIterable<?>> appFn)
        Given another instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports.

        In this case, calculate the cartesian product of applications of all functions in appFn to all values wrapped by this LambdaIterable.

        Specified by:
        zip in interface Applicative<A,​LambdaIterable<?>>
        Specified by:
        zip in interface Monad<A,​LambdaIterable<?>>
        Specified by:
        zip in interface MonadRec<A,​LambdaIterable<?>>
        Type Parameters:
        B - the new parameter type
        Parameters:
        appFn - the other applicative instance
        Returns:
        the zipped LambdaIterable
      • lazyZip

        public <B> Lazy<LambdaIterable<B>> lazyZip​(Lazy<? extends Applicative<Fn1<? super A,​? extends B>,​LambdaIterable<?>>> lazyAppFn)
        Given a lazy instance of this applicative over a mapping function, "zip" the two instances together using whatever application semantics the current applicative supports. This is useful for applicatives that support lazy evaluation and early termination.
        Specified by:
        lazyZip in interface Applicative<A,​LambdaIterable<?>>
        Specified by:
        lazyZip in interface Monad<A,​LambdaIterable<?>>
        Specified by:
        lazyZip in interface MonadRec<A,​LambdaIterable<?>>
        Type Parameters:
        B - the resulting applicative parameter type
        Parameters:
        lazyAppFn - the lazy other applicative instance
        Returns:
        the mapped applicative
        See Also:
        Maybe, Either
      • flatMap

        public <B> LambdaIterable<B> flatMap​(Fn1<? super A,​? extends Monad<B,​LambdaIterable<?>>> f)
        Chain dependent computations that may continue or short-circuit based on previous results.
        Specified by:
        flatMap in interface Monad<A,​LambdaIterable<?>>
        Specified by:
        flatMap in interface MonadRec<A,​LambdaIterable<?>>
        Type Parameters:
        B - the resulting monad parameter type
        Parameters:
        f - the dependent computation over A
        Returns:
        the new monad instance
      • traverse

        public <B,​App extends Applicative<?,​App>,​TravB extends Traversable<B,​LambdaIterable<?>>,​AppTrav extends Applicative<TravB,​App>> AppTrav traverse​(Fn1<? super A,​? extends Applicative<B,​App>> fn,
                                                                                                                                                                                             Fn1<? super TravB,​? extends AppTrav> pure)
        Apply fn to each element of this traversable from left to right, and collapse the results into a single resulting applicative, potentially with the assistance of the applicative's pure function.
        Specified by:
        traverse in interface Traversable<A,​LambdaIterable<?>>
        Type Parameters:
        B - the resulting element type
        App - the result applicative type
        TravB - this Traversable instance over B
        AppTrav - the full inferred resulting type from the traversal
        Parameters:
        fn - the function to apply
        pure - the applicative pure function
        Returns:
        the traversed Traversable, wrapped inside an applicative
      • equals

        public boolean equals​(java.lang.Object other)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • wrap

        public static <A> LambdaIterable<A> wrap​(java.lang.Iterable<? extends A> as)
        Wrap an Iterable in a LambdaIterable.
        Type Parameters:
        A - the Iterable element type
        Parameters:
        as - the Iterable
        Returns:
        the Iterable wrapped in a LambdaIterable