Class Service<S>

  • Type Parameters:
    S - the service type
    All Implemented Interfaces:
    com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>, com.jnape.palatable.lambda.functor.Functor<S,​Service<?>>, com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>, com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>

    public class Service<S>
    extends Object
    implements com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
    Service is a monad representing the effect of resolving the dependencies of a service object so that it may be constructed. Services require the use of an App in order to perform this resolution. A pure Service is one that has no dependencies.
    See Also:
    for more thorough coverage of Service usage.
    • Constructor Detail

      • Service

        public Service()
    • Method Detail

      • pure

        public <B> Service<B> pure​(B b)
        Specified by:
        pure in interface com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>
        Specified by:
        pure in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        pure in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • fmap

        public <B> Service<B> fmap​(com.jnape.palatable.lambda.functions.Fn1<? super S,​? extends B> fn)
        Specified by:
        fmap in interface com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.functor.Functor<S,​Service<?>>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        fmap in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • zip

        public <B> Service<B> zip​(com.jnape.palatable.lambda.functor.Applicative<com.jnape.palatable.lambda.functions.Fn1<? super S,​? extends B>,​Service<?>> appFn)
        Specified by:
        zip in interface com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>
        Specified by:
        zip in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        zip in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • flatMap

        public <B> Service<B> flatMap​(com.jnape.palatable.lambda.functions.Fn1<? super S,​? extends com.jnape.palatable.lambda.monad.Monad<B,​Service<?>>> f)
        Specified by:
        flatMap in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        flatMap in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • trampolineM

        public <B> Service<B> trampolineM​(com.jnape.palatable.lambda.functions.Fn1<? super S,​? extends com.jnape.palatable.lambda.monad.MonadRec<com.jnape.palatable.lambda.functions.recursion.RecursiveResult<S,​B>,​Service<?>>> f)
        Specified by:
        trampolineM in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • lazyZip

        public <B> com.jnape.palatable.lambda.functor.builtin.Lazy<Service<B>> lazyZip​(com.jnape.palatable.lambda.functor.builtin.Lazy<? extends com.jnape.palatable.lambda.functor.Applicative<com.jnape.palatable.lambda.functions.Fn1<? super S,​? extends B>,​Service<?>>> lazyAppFn)
        Specified by:
        lazyZip in interface com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>
        Specified by:
        lazyZip in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        lazyZip in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • discardL

        public <B> Service<B> discardL​(com.jnape.palatable.lambda.functor.Applicative<B,​Service<?>> appB)
        Specified by:
        discardL in interface com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>
        Specified by:
        discardL in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        discardL in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • discardR

        public <B> Service<S> discardR​(com.jnape.palatable.lambda.functor.Applicative<B,​Service<?>> appB)
        Specified by:
        discardR in interface com.jnape.palatable.lambda.functor.Applicative<S,​Service<?>>
        Specified by:
        discardR in interface com.jnape.palatable.lambda.monad.Monad<S,​Service<?>>
        Specified by:
        discardR in interface com.jnape.palatable.lambda.monad.MonadRec<S,​Service<?>>
      • service

        public static <S> Service<S> service​(com.jnape.palatable.lambda.io.IO<S> service)
        Constructs a pure Service around an IO that produces the service object.
        Type Parameters:
        S - the service type
        Parameters:
        service - the service object, within IO
        Returns:
        a Service that resolves to S
      • serviceRef

        public static <S> Service<S> serviceRef​(ServiceHandle<S> handle)
        Constructs a Service by references using a handle.
        Type Parameters:
        S - the service type
        Parameters:
        handle - the handle to reference
        Returns:
        A reference Service
      • service

        public static <S,​Dep> Service<S> service​(ServiceHandle<Dep> handle,
                                                       com.jnape.palatable.lambda.functions.Fn1<Dep,​Service<S>> fn)
        Constructs a Service with one dependency. The dependency is referenced by its ServiceHandle, and made available in the scope of a function that then produces a Service
        Type Parameters:
        S - the service type
        Dep - the dependency type
        Parameters:
        handle - a ServiceHandle for the dependency
        fn - a function that can produce the service given the dependency
        Returns:
        a Service that resolves to S
      • service

        public static <S,​Dep1,​Dep2> Service<S> service​(ServiceHandle<Dep1> handle1,
                                                                   ServiceHandle<Dep2> handle2,
                                                                   com.jnape.palatable.lambda.functions.Fn2<Dep1,​Dep2,​Service<S>> fn)
        Constructs a Service with two dependencies. The dependencies are referenced by their ServiceHandles, and made available in the scope of a function that then produces a Service.
        Type Parameters:
        S - the service type
        Dep1 - the first dependency type
        Dep2 - the second dependency type
        Parameters:
        handle1 - a ServiceHandle for the first dependency
        handle2 - a ServiceHandle for the second dependency
        fn - a function that can produce the service given the dependencies
        Returns:
        a Service that resolves to S
      • service

        public static <S,​Dep1,​Dep2,​Dep3> Service<S> service​(ServiceHandle<Dep1> handle1,
                                                                              ServiceHandle<Dep2> handle2,
                                                                              ServiceHandle<Dep3> handle3,
                                                                              com.jnape.palatable.lambda.functions.Fn3<Dep1,​Dep2,​Dep3,​Service<S>> fn)
        Constructs a Service with three dependencies. The dependencies are referenced by their ServiceHandles, and made available in the scope of a function that then produces a Service.
        Type Parameters:
        S - the service type
        Dep1 - the first dependency type
        Dep2 - the second dependency type
        Dep3 - the third dependency type
        Parameters:
        handle1 - a ServiceHandle for the first dependency
        handle2 - a ServiceHandle for the second dependency
        handle3 - a ServiceHandle for the third dependency
        fn - a function that can produce the service given the dependencies
        Returns:
        a Service that resolves to S
      • service

        public static <S,​Dep1,​Dep2,​Dep3,​Dep4> Service<S> service​(ServiceHandle<Dep1> handle1,
                                                                                         ServiceHandle<Dep2> handle2,
                                                                                         ServiceHandle<Dep3> handle3,
                                                                                         ServiceHandle<Dep4> handle4,
                                                                                         com.jnape.palatable.lambda.functions.Fn4<Dep1,​Dep2,​Dep3,​Dep4,​Service<S>> fn)
        Constructs a Service with four dependencies. The dependencies are referenced by their ServiceHandles, and made available in the scope of a function that then produces a Service.
        Type Parameters:
        S - the service type
        Dep1 - the first dependency type
        Dep2 - the second dependency type
        Dep3 - the third dependency type
        Dep4 - the fourth dependency type
        Parameters:
        handle1 - a ServiceHandle for the first dependency
        handle2 - a ServiceHandle for the second dependency
        handle3 - a ServiceHandle for the third dependency
        handle4 - a ServiceHandle for the fourth dependency
        fn - a function that can produce the service given the dependencies
        Returns:
        a Service that resolves to S
      • service

        public static <S,​Dep1,​Dep2,​Dep3,​Dep4,​Dep5> Service<S> service​(ServiceHandle<Dep1> handle1,
                                                                                                    ServiceHandle<Dep2> handle2,
                                                                                                    ServiceHandle<Dep3> handle3,
                                                                                                    ServiceHandle<Dep4> handle4,
                                                                                                    ServiceHandle<Dep5> handle5,
                                                                                                    com.jnape.palatable.lambda.functions.Fn5<Dep1,​Dep2,​Dep3,​Dep4,​Dep5,​Service<S>> fn)
        Constructs a Service with five dependencies. The dependencies are referenced by their ServiceHandles, and made available in the scope of a function that then produces a Service.
        Type Parameters:
        S - the service type
        Dep1 - the first dependency type
        Dep2 - the second dependency type
        Dep3 - the third dependency type
        Dep4 - the fourth dependency type
        Dep5 - the fifth dependency type
        Parameters:
        handle1 - a ServiceHandle for the first dependency
        handle2 - a ServiceHandle for the second dependency
        handle3 - a ServiceHandle for the third dependency
        handle4 - a ServiceHandle for the fourth dependency
        handle5 - a ServiceHandle for the fifth dependency
        fn - a function that can produce the service given the dependencies
        Returns:
        a Service that resolves to S
      • service

        public static <S,​Dep1,​Dep2,​Dep3,​Dep4,​Dep5,​Dep6> Service<S> service​(ServiceHandle<Dep1> handle1,
                                                                                                               ServiceHandle<Dep2> handle2,
                                                                                                               ServiceHandle<Dep3> handle3,
                                                                                                               ServiceHandle<Dep4> handle4,
                                                                                                               ServiceHandle<Dep5> handle5,
                                                                                                               ServiceHandle<Dep6> handle6,
                                                                                                               com.jnape.palatable.lambda.functions.Fn6<Dep1,​Dep2,​Dep3,​Dep4,​Dep5,​Dep6,​Service<S>> fn)
        Constructs a Service with six dependencies. The dependencies are referenced by their ServiceHandles, and made available in the scope of a function that then produces a Service.
        Type Parameters:
        S - the service type
        Dep1 - the first dependency type
        Dep2 - the second dependency type
        Dep3 - the third dependency type
        Dep4 - the fourth dependency type
        Dep5 - the fifth dependency type
        Dep6 - the sixth dependency type
        Parameters:
        handle1 - a ServiceHandle for the first dependency
        handle2 - a ServiceHandle for the second dependency
        handle3 - a ServiceHandle for the third dependency
        handle4 - a ServiceHandle for the fourth dependency
        handle5 - a ServiceHandle for the fifth dependency
        handle6 - a ServiceHandle for the sixth dependency
        fn - a function that can produce the service given the dependencies
        Returns:
        a Service that resolves to S
      • service

        public static <S,​Dep1,​Dep2,​Dep3,​Dep4,​Dep5,​Dep6,​Dep7> Service<S> service​(ServiceHandle<Dep1> handle1,
                                                                                                                          ServiceHandle<Dep2> handle2,
                                                                                                                          ServiceHandle<Dep3> handle3,
                                                                                                                          ServiceHandle<Dep4> handle4,
                                                                                                                          ServiceHandle<Dep5> handle5,
                                                                                                                          ServiceHandle<Dep6> handle6,
                                                                                                                          ServiceHandle<Dep7> handle7,
                                                                                                                          com.jnape.palatable.lambda.functions.Fn7<Dep1,​Dep2,​Dep3,​Dep4,​Dep5,​Dep6,​Dep7,​Service<S>> fn)
        Constructs a Service with seven dependencies. The dependencies are referenced by their ServiceHandles, and made available in the scope of a function that then produces a Service.
        Type Parameters:
        S - the service type
        Dep1 - the first dependency type
        Dep2 - the second dependency type
        Dep3 - the third dependency type
        Dep4 - the fourth dependency type
        Dep5 - the fifth dependency type
        Dep6 - the sixth dependency type
        Dep7 - the seventh dependency type
        Parameters:
        handle1 - a ServiceHandle for the first dependency
        handle2 - a ServiceHandle for the second dependency
        handle3 - a ServiceHandle for the third dependency
        handle4 - a ServiceHandle for the fourth dependency
        handle5 - a ServiceHandle for the fifth dependency
        handle6 - a ServiceHandle for the sixth dependency
        handle7 - a ServiceHandle for the seventh dependency
        fn - a function that can produce the service given the dependencies
        Returns:
        a Service that resolves to S