Package org.movealong.sly.app
Class Service<S>
- java.lang.Object
-
- org.movealong.sly.app.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<?>>
Serviceis a monad representing the effect of resolving the dependencies of a service object so that it may be constructed.Services require the use of anAppin order to perform this resolution. A pureServiceis one that has no dependencies.
-
-
Constructor Summary
Constructors Constructor Description Service()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <B> Service<B>discardL(com.jnape.palatable.lambda.functor.Applicative<B,Service<?>> appB)<B> Service<S>discardR(com.jnape.palatable.lambda.functor.Applicative<B,Service<?>> appB)<B> Service<B>flatMap(com.jnape.palatable.lambda.functions.Fn1<? super S,? extends com.jnape.palatable.lambda.monad.Monad<B,Service<?>>> f)<B> Service<B>fmap(com.jnape.palatable.lambda.functions.Fn1<? super S,? extends B> fn)<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)<B> Service<B>pure(B b)static <S> Service<S>service(com.jnape.palatable.lambda.io.IO<S> service)Constructs a pureServicearound anIOthat produces the service object.static <S,Dep>
Service<S>service(ServiceHandle<Dep> handle, com.jnape.palatable.lambda.functions.Fn1<Dep,Service<S>> fn)Constructs aServicewith one dependency.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 aServicewith two dependencies.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 aServicewith three dependencies.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 aServicewith four dependencies.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 aServicewith five dependencies.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 aServicewith six dependencies.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 aServicewith seven dependencies.static <S> Service<S>serviceRef(ServiceHandle<S> handle)Constructs aServiceby references using a handle.<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)<B> Service<B>zip(com.jnape.palatable.lambda.functor.Applicative<com.jnape.palatable.lambda.functions.Fn1<? super S,? extends B>,Service<?>> appFn)
-
-
-
Method Detail
-
pure
public <B> Service<B> pure(B b)
-
fmap
public <B> Service<B> fmap(com.jnape.palatable.lambda.functions.Fn1<? super S,? extends B> fn)
- Specified by:
fmapin interfacecom.jnape.palatable.lambda.functor.Applicative<S,Service<?>>- Specified by:
fmapin interfacecom.jnape.palatable.lambda.functor.Functor<S,Service<?>>- Specified by:
fmapin interfacecom.jnape.palatable.lambda.monad.Monad<S,Service<?>>- Specified by:
fmapin interfacecom.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)
-
flatMap
public <B> Service<B> flatMap(com.jnape.palatable.lambda.functions.Fn1<? super S,? extends com.jnape.palatable.lambda.monad.Monad<B,Service<?>>> f)
-
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)
-
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)
-
discardL
public <B> Service<B> discardL(com.jnape.palatable.lambda.functor.Applicative<B,Service<?>> appB)
-
discardR
public <B> Service<S> discardR(com.jnape.palatable.lambda.functor.Applicative<B,Service<?>> appB)
-
service
public static <S> Service<S> service(com.jnape.palatable.lambda.io.IO<S> service)
Constructs a pureServicearound anIOthat produces the service object.- Type Parameters:
S- the service type- Parameters:
service- the service object, withinIO- Returns:
- a
Servicethat resolves toS
-
serviceRef
public static <S> Service<S> serviceRef(ServiceHandle<S> handle)
Constructs aServiceby 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 aServicewith one dependency. The dependency is referenced by itsServiceHandle, and made available in the scope of a function that then produces aService- Type Parameters:
S- the service typeDep- the dependency type- Parameters:
handle- aServiceHandlefor the dependencyfn- a function that can produce the service given the dependency- Returns:
- a
Servicethat resolves toS
-
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 aServicewith two dependencies. The dependencies are referenced by theirServiceHandles, and made available in the scope of a function that then produces aService.- Type Parameters:
S- the service typeDep1- the first dependency typeDep2- the second dependency type- Parameters:
handle1- aServiceHandlefor the first dependencyhandle2- aServiceHandlefor the second dependencyfn- a function that can produce the service given the dependencies- Returns:
- a
Servicethat resolves toS
-
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 aServicewith three dependencies. The dependencies are referenced by theirServiceHandles, and made available in the scope of a function that then produces aService.- Type Parameters:
S- the service typeDep1- the first dependency typeDep2- the second dependency typeDep3- the third dependency type- Parameters:
handle1- aServiceHandlefor the first dependencyhandle2- aServiceHandlefor the second dependencyhandle3- aServiceHandlefor the third dependencyfn- a function that can produce the service given the dependencies- Returns:
- a
Servicethat resolves toS
-
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 aServicewith four dependencies. The dependencies are referenced by theirServiceHandles, and made available in the scope of a function that then produces aService.- Type Parameters:
S- the service typeDep1- the first dependency typeDep2- the second dependency typeDep3- the third dependency typeDep4- the fourth dependency type- Parameters:
handle1- aServiceHandlefor the first dependencyhandle2- aServiceHandlefor the second dependencyhandle3- aServiceHandlefor the third dependencyhandle4- aServiceHandlefor the fourth dependencyfn- a function that can produce the service given the dependencies- Returns:
- a
Servicethat resolves toS
-
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 aServicewith five dependencies. The dependencies are referenced by theirServiceHandles, and made available in the scope of a function that then produces aService.- Type Parameters:
S- the service typeDep1- the first dependency typeDep2- the second dependency typeDep3- the third dependency typeDep4- the fourth dependency typeDep5- the fifth dependency type- Parameters:
handle1- aServiceHandlefor the first dependencyhandle2- aServiceHandlefor the second dependencyhandle3- aServiceHandlefor the third dependencyhandle4- aServiceHandlefor the fourth dependencyhandle5- aServiceHandlefor the fifth dependencyfn- a function that can produce the service given the dependencies- Returns:
- a
Servicethat resolves toS
-
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 aServicewith six dependencies. The dependencies are referenced by theirServiceHandles, and made available in the scope of a function that then produces aService.- Type Parameters:
S- the service typeDep1- the first dependency typeDep2- the second dependency typeDep3- the third dependency typeDep4- the fourth dependency typeDep5- the fifth dependency typeDep6- the sixth dependency type- Parameters:
handle1- aServiceHandlefor the first dependencyhandle2- aServiceHandlefor the second dependencyhandle3- aServiceHandlefor the third dependencyhandle4- aServiceHandlefor the fourth dependencyhandle5- aServiceHandlefor the fifth dependencyhandle6- aServiceHandlefor the sixth dependencyfn- a function that can produce the service given the dependencies- Returns:
- a
Servicethat resolves toS
-
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 aServicewith seven dependencies. The dependencies are referenced by theirServiceHandles, and made available in the scope of a function that then produces aService.- Type Parameters:
S- the service typeDep1- the first dependency typeDep2- the second dependency typeDep3- the third dependency typeDep4- the fourth dependency typeDep5- the fifth dependency typeDep6- the sixth dependency typeDep7- the seventh dependency type- Parameters:
handle1- aServiceHandlefor the first dependencyhandle2- aServiceHandlefor the second dependencyhandle3- aServiceHandlefor the third dependencyhandle4- aServiceHandlefor the fourth dependencyhandle5- aServiceHandlefor the fifth dependencyhandle6- aServiceHandlefor the sixth dependencyhandle7- aServiceHandlefor the seventh dependencyfn- a function that can produce the service given the dependencies- Returns:
- a
Servicethat resolves toS
-
-