Skip to content

Commit

Permalink
Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
geirolz committed Sep 18, 2024
1 parent c8da9af commit 2e21c34
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 20 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/com/geirolz/app/toolkit/App.scala
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ object App extends AppFailureSyntax:
inline def apply[F[+_]: Async: Parallel]: AppBuilder.Simple[F] =
AppBuilder.simple[F]

inline def apply[F[+_]: Async: Parallel, FAILURE: ClassTag]: AppBuilder[F, FAILURE] =
inline def apply[F[+_]: Async: Parallel, FAILURE <: Matchable: ClassTag]: AppBuilder[F, FAILURE] =
AppBuilder.withFailure[F, FAILURE]

sealed transparent trait AppFailureSyntax:
Expand Down
22 changes: 11 additions & 11 deletions core/src/main/scala/com/geirolz/app/toolkit/AppBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import com.geirolz.app.toolkit.novalues.NoFailure.NotNoFailure
import com.geirolz.app.toolkit.novalues.{NoConfig, NoDependencies, NoFailure, NoResources}

import java.time.LocalDateTime
import scala.reflect.ClassTag
import scala.reflect.Typeable

final class AppBuilder[F[+_]: Async: Parallel, FAILURE: ClassTag]:
final class AppBuilder[F[+_]: Async: Parallel, FAILURE <: Matchable]:

inline def withInfo(
name: String = "",
Expand Down Expand Up @@ -52,12 +52,12 @@ object AppBuilder:
inline def simple[F[+_]: Async: Parallel]: AppBuilder.Simple[F] =
new AppBuilder[F, NoFailure]

inline def withFailure[F[+_]: Async: Parallel, FAILURE: ClassTag: NotNoFailure]: AppBuilder[F, FAILURE] =
inline def withFailure[F[+_]: Async: Parallel, FAILURE <: Matchable: NotNoFailure]: AppBuilder[F, FAILURE] =
new AppBuilder[F, FAILURE]

final class SelectResAndDeps[
F[+_]: Async: Parallel,
FAILURE: ClassTag,
FAILURE <: Matchable,
INFO <: SimpleAppInfo[?],
LOGGER_T[_[_]]: LoggerAdapter,
CONFIG: Show,
Expand Down Expand Up @@ -131,7 +131,7 @@ object AppBuilder:
dependsOn[NoDependencies, FAILURE](Resource.pure(NoDependencies.value))

/** Dependencies are loaded into context and released at the end of the application. */
inline def dependsOn[DEPENDENCIES, FAILURE2 <: FAILURE: ClassTag](
inline def dependsOn[DEPENDENCIES <: Matchable: Typeable, FAILURE2 <: FAILURE & Matchable: Typeable](
f: AppContext.NoDeps[INFO, LOGGER_T[F], CONFIG, RESOURCES] ?=> Resource[F, FAILURE2 | DEPENDENCIES]
): AppBuilder.SelectProvide[F, FAILURE, INFO, LOGGER_T, CONFIG, RESOURCES, DEPENDENCIES] =
dependsOnE[DEPENDENCIES, FAILURE2](f.map {
Expand All @@ -155,7 +155,7 @@ object AppBuilder:

private def copyWith[
G[+_]: Async: Parallel,
FAILURE2: ClassTag,
FAILURE2 <: Matchable,
INFO2 <: SimpleAppInfo[?],
LOGGER_T2[_[_]]: LoggerAdapter,
CONFIG2: Show,
Expand Down Expand Up @@ -199,7 +199,7 @@ object AppBuilder:
copy(beforeProvidingTask = d => this.beforeProvidingTask(d) >> f(using d))

// ------- PROVIDE -------
def provideOne[FAILURE2 <: FAILURE: ClassTag](
def provideOne[FAILURE2 <: FAILURE & Matchable: Typeable](
f: AppContext[INFO, LOGGER_T[F], CONFIG, DEPENDENCIES, RESOURCES] ?=> F[FAILURE2 | Unit]
): App[F, FAILURE, INFO, LOGGER_T, CONFIG, RESOURCES, DEPENDENCIES] =
provideOneE[FAILURE2](f.map {
Expand All @@ -218,12 +218,12 @@ object AppBuilder:
provideParallelAttemptFE[FAILURE2](f.map(_.map(v => List(v.map(_.asRight[FAILURE2])))))

// provide
def provideParallel[FAILURE2 <: FAILURE: ClassTag](
def provideParallel[FAILURE2 <: FAILURE & Matchable: Typeable](
f: AppContext[INFO, LOGGER_T[F], CONFIG, DEPENDENCIES, RESOURCES] ?=> List[F[FAILURE2 | Unit]]
): App[F, FAILURE, INFO, LOGGER_T, CONFIG, RESOURCES, DEPENDENCIES] =
provideParallelE(f.map(_.map {
case failure: FAILURE2 => Left(failure)
case _: Unit => Right(())
case failure: FAILURE2 => Left(failure)
}))

inline def provideParallelE[FAILURE2 <: FAILURE](
Expand All @@ -232,12 +232,12 @@ object AppBuilder:
provideParallelFE[FAILURE2](f.pure[F])

// provideF
def provideParallelF[FAILURE2 <: FAILURE: ClassTag](
def provideParallelF[FAILURE2 <: FAILURE & Matchable: Typeable](
f: AppContext[INFO, LOGGER_T[F], CONFIG, DEPENDENCIES, RESOURCES] ?=> F[List[F[FAILURE2 | Unit]]]
)(using DummyImplicit): App[F, FAILURE, INFO, LOGGER_T, CONFIG, RESOURCES, DEPENDENCIES] =
provideParallelFE(f.map(_.map(_.map {
case failure: FAILURE2 => Left(failure)
case _: Unit => Right(())
case failure: FAILURE2 => Left(failure)
})))

inline def provideParallelFE[FAILURE2 <: FAILURE](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.geirolz.app.toolkit.error

import cats.data.NonEmptyList
import cats.kernel.Semigroup
import scala.reflect.Typeable

trait MultiError[E]:

Expand All @@ -22,7 +23,7 @@ trait MultiError[E]:

object MultiError:

def semigroup[E, ME <: E & MultiError[E]](f: NonEmptyList[E] => ME): Semigroup[E] =
def semigroup[E <: Matchable, ME <: E & MultiError[E]: Typeable](f: NonEmptyList[E] => ME): Semigroup[E] =
(x: E, y: E) =>
(x, y) match
case (m1: MultiError[?], m2: MultiError[?]) =>
Expand Down
6 changes: 4 additions & 2 deletions docs/source/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ object KafkaConsumer:
import cats.effect.{ExitCode, IO, IOApp}
import com.geirolz.app.toolkit.*
import com.geirolz.app.toolkit.logger.Logger
import java.time.LocalDateTime

object Main extends IOApp:
override def run(args: List[String]): IO[ExitCode] =
Expand All @@ -119,11 +120,12 @@ object Main extends IOApp:
name = "toolkit",
version = "0.0.1",
scalaVersion = "2.13.10",
sbtVersion = "1.8.0"
sbtVersion = "1.8.0",
builtOn = LocalDateTime.now()
)
)
.withConsoleLogger()
.withConfigF(IO.pure(Config("localhost", 8080)))
.withConfig(IO.pure(Config("localhost", 8080)))
.dependsOn(AppDependencyServices.resource)
.beforeProviding(ctx.logger.info("CUSTOM PRE-PROVIDING"))
.provideOne(
Expand Down
10 changes: 7 additions & 3 deletions docs/source/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import cats.Show
import cats.effect.IO
import com.geirolz.app.toolkit.{App, SimpleAppInfo}
import com.geirolz.app.toolkit.config.pureconfig.*
import java.time.LocalDateTime

case class TestConfig(value: String)

Expand All @@ -66,10 +67,11 @@ App[IO]
name = "toolkit",
version = "0.0.1",
scalaVersion = "2.13.10",
sbtVersion = "1.8.0"
sbtVersion = "1.8.0",
builtOn = LocalDateTime.now()
)
)
.withConfigF(pureconfigLoader[IO, TestConfig])
.withConfig(pureconfigLoader[IO, TestConfig])
.withoutDependencies
.provideOne(IO.unit)
.run()
Expand Down Expand Up @@ -157,6 +159,7 @@ import cats.Show
import cats.effect.IO
import com.geirolz.app.toolkit.fly4s.*
import com.geirolz.app.toolkit.*
import java.time.LocalDateTime

case class TestConfig(dbUrl: String, dbUser: Option[String], dbPassword: Option[Array[Char]])

Expand All @@ -169,7 +172,8 @@ App[IO]
name = "toolkit",
version = "0.0.1",
scalaVersion = "2.13.10",
sbtVersion = "1.8.0"
sbtVersion = "1.8.0",
builtOn = LocalDateTime.now()
)
)
.withConfigPure(
Expand Down
3 changes: 1 addition & 2 deletions project/PrjCompilerOptions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ object PrjCompilerOptions {
ScalacOptions.languageStrictEquality,
ScalacOptions.languageHigherKinds,
ScalacOptions.languageExistentials,
ScalacOptions.other("-language:dynamics"),

// warns
// ScalacOptions.fatalWarnings,
ScalacOptions.fatalWarnings,
ScalacOptions.warnValueDiscard,
ScalacOptions.warnNonUnitStatement,
ScalacOptions.warnExtraImplicit,
Expand Down

0 comments on commit 2e21c34

Please sign in to comment.