Class App

    • Constructor Summary

      Constructors 
      Constructor Description
      App()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​App,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<App>> bind​(ServiceHandle<S> handle, Service<S> service)
      Binds a Service to a ServiceHandle.
      static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​S,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<S>> resolve​(Service<S> service)
      Resolves a service.
      static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​S,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<S>> resolve​(ServiceHandle<S> handle)
      Resolves a service by its ServiceHandle.
      static <R,​F extends com.jnape.palatable.lambda.functor.Functor<?,​F>,​FR extends com.jnape.palatable.lambda.functor.Functor<R,​F>,​A extends Runner<R,​F,​FR>>
      FR
      run​(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​A,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<A>> application)
      Runs an application in the form of an application function that yields n Runner that produces a Functor that bears the ultimate return type.
      static <S extends Starter<com.jnape.palatable.lambda.io.IO<?>>>
      void
      start​(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​S,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<S>> application)
      Starts an application in the form of an application function that yields a Starter, which in turn handles starting and stopping the long-running components of the application.
    • Constructor Detail

      • App

        public App()
    • Method Detail

      • bind

        public static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​App,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<App>> bind​(ServiceHandle<S> handle,
                                                                                                                                                                                             Service<S> service)
        Binds a Service to a ServiceHandle. Binding a service to a handle makes the service accessible to other services via resolution. A handle can only be bound once, and rebinding a handle will result in an exception. The service that the supplied handle is bound to it may not resolve other handles that are bound to services that resolve the supplied handle, including indirectly. This will not cause an error immediately, but will if any handle in the cycle is later resolved.
        Type Parameters:
        S - the service type
        Parameters:
        handle - the ServiceHandle to bind the service to
        service - the Service being bound
        Returns:
        A Kleisli function that forms part of the composition of an application
      • resolve

        public static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​S,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<S>> resolve​(Service<S> service)
        Resolves a service. Composing a Kleisli returned from resolve onto a Kleisli composed of one or more bind calls will produce an application function suitable for use with run or start.
        Type Parameters:
        S - the service object type
        Parameters:
        service - the Service
        Returns:
        An application function
      • resolve

        public static <S> com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​S,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<S>> resolve​(ServiceHandle<S> handle)
        Resolves a service by its ServiceHandle. The handle must have been previously bound using bind to a Service that has a carrier of type S. Composing a Kleisli returned from resolve onto a Kleisli composed of one or more bind calls will produce an application function suitable for use with run.
        Type Parameters:
        S - the Runner type
        Parameters:
        handle - handle for the application service
        Returns:
        An application function
      • run

        public static <R,​F extends com.jnape.palatable.lambda.functor.Functor<?,​F>,​FR extends com.jnape.palatable.lambda.functor.Functor<R,​F>,​A extends Runner<R,​F,​FR>> FR run​(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​A,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<A>> application)
        Runs an application in the form of an application function that yields n Runner that produces a Functor that bears the ultimate return type. run will perform the IO that results from applying the function exactly once, throw an exception if that IO is in its error mode, and otherwise return the IO's result.
        Type Parameters:
        R - carrier type of the application return
        F - Functor type of the application return
        FR - the application return type
        A - the Runner type
        Parameters:
        application - the Kleisli function representing the application
        Returns:
        the result of running the application
      • start

        public static <S extends Starter<com.jnape.palatable.lambda.io.IO<?>>> void start​(com.jnape.palatable.lambda.functions.specialized.Kleisli<App,​S,​com.jnape.palatable.lambda.io.IO<?>,​com.jnape.palatable.lambda.io.IO<S>> application)
        Starts an application in the form of an application function that yields a Starter, which in turn handles starting and stopping the long-running components of the application.
        Type Parameters:
        S - the Starter type
        Parameters:
        application - the application function