Tagless Final Encoding
Closed this issue · 1 comments
vlovgr commented
The idea is to parametrise ConfigSource
with an additional type parameter F[_]
, so that the type signature becomes ConfigSource[F[_], Key]
, and so that it now reads keys with return type F[ConfigSourceEntry[Key]]
.
Remaining parts of Ciris, including documentation, will need to be updated to account for the type parameterisation. Existing functions can use the Id
type as context. New functions will need to be created where the context can be specified or inferred.
This would allow to write code similar to the following, replacing Future
with some other type for which you can define a Monad
instance.
type F[A] = Future[A]
val source: ConfigSource[F, String] = ???
def fetch[Value: ConfigReader](key: String): F[ConfigValue[Value]] = ???
val sum: F[BigDecimal] =
loadConfig(
fetch[BigDecimal]("FIRST_KEY"),
fetch[Int]("SECOND_KEY"),
fetch[Double]("THIRD_KEY")
)(_ + _ + _)
This work will also involve:
- Replicate parts of
Id
,Applicative
, andMonad
from Cats in the core module.
This is to ensure we stay dependency-free in the core module. - Provide conversions from Cats' instances to the core module's instances.
These conversions should fit within the same Cats module described in #38.