This repository presents a solution to compile-time dependency injection problem over pure functions.
Given a set of functions
{Fi: (Pi,1, .., Pi,Ni) => Ri | i ∈ 1..N}
,
the functions are sorted in such way σ
that each type from the set
{Pσ(i),1, .., Pσ(i),Nσ(i)}
is uniquely covered by a type from the set of return types
{Rσ(k) | k ∈ 1..i-1}
.
If such an ordering exists, the functions of these types may be combined into a single function
S: () => (R1, .., RN)
.
The present implementation combines given functions to an equivalent function with shapeless' heterogeneous list as
return type
() => Rσ(N) :: Rσ(N-1) :: .. :: Rσ(1) :: HNil
and allows to retrieve the desired subset of the computed values, ordered arbitrarily.
Example. See TopologicalSortTest.scala
.