Skip to content

Commit

Permalink
Merge pull request #998 from leviysoft/feature/remove-optics
Browse files Browse the repository at this point in the history
Remove optics-* modules in favour of separate library `tf.tofu.glass`
  • Loading branch information
FunFunFine authored Aug 29, 2022
2 parents 365e6a6 + 0fa6118 commit 55d8e87
Show file tree
Hide file tree
Showing 87 changed files with 103 additions and 2,770 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
run: sbt ++${{ matrix.scala }} docs/mdoc

- name: Compress target directories
run: tar cf targets.tar modules/logging/interop/shapeless/target modules/kernel/target modules/logging/target examples/target modules/doobie/core-ce3/target modules/concurrent/target modules/logging/layout/target modules/optics/core/target modules/kernelCE2Interop/target modules/doobie/core/target modules/zio/target modules/fs2-ce3/target examples-ce3/target tofu-docs/target modules/zio/logging/target modules/core3/target modules/kernel/interop/cats-mtl/target modules/config/target modules/optics/macro/target modules/doobie/logging-ce3/target modules/kernelCE3Interop/target modules/zio/core/target modules/streams/target modules/logging/structured/target modules/logging/interop/logstash-logback/target modules/logging/interop/log4cats/target modules/doobie/logging/target modules/enums/target target modules/fs2/target modules/logging/derivation/target modules/logging/interop/refined/target modules/higherKindCore/target modules/derivation/target modules/core/target modules/observable/target modules/optics/interop/target modules/memo/target modules/env/target project/target
run: tar cf targets.tar modules/logging/interop/shapeless/target modules/kernel/target modules/logging/target examples/target modules/doobie/core-ce3/target modules/concurrent/target modules/logging/layout/target modules/kernelCE2Interop/target modules/doobie/core/target modules/zio/target modules/fs2-ce3/target examples-ce3/target tofu-docs/target modules/zio/logging/target modules/core3/target modules/kernel/interop/cats-mtl/target modules/config/target modules/doobie/logging-ce3/target modules/kernelCE3Interop/target modules/zio/core/target modules/streams/target modules/logging/structured/target modules/logging/interop/logstash-logback/target modules/logging/interop/log4cats/target modules/doobie/logging/target modules/enums/target target modules/fs2/target modules/logging/derivation/target modules/logging/interop/refined/target modules/higherKindCore/target modules/derivation/target modules/core/target modules/observable/target modules/memo/target modules/env/target project/target

- name: Upload target directories
uses: actions/upload-artifact@v2
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ of `"tofu"`):
* `tofu-logging-log4cats` for interop with [Log4Cats](https://github.com/typelevel/log4cats)
* `tofu-memo` for caching utils
* `tofu-observable` for `monix.reactive.Observable` utils
* `tofu-optics-core` for optics core (Optics typeclasses)
* `tofu-optics-interop` for optics interop with [Monocle](https://github.com/julien-truffaut/Monocle)
* `tofu-optics-macro` for macro optics generators
* `tofu-zio-interop` for interop with [ZIO](https://zio.dev) (core, logging)
* `tofu-zio-core` for ZIO instances only
* `tofu-zio-logging` for ZIO logging only
Expand Down
60 changes: 16 additions & 44 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ lazy val higherKindCore = project
lazy val kernel = project
.in(file("modules/kernel"))
.settings(defaultSettings)
.dependsOn(opticsCore, higherKindCore)
.dependsOn(higherKindCore)
.settings(
defaultSettings,
name := "tofu-kernel"
name := "tofu-kernel",
libraryDependencies += glassCore
)

lazy val kernelCE2Interop = project
Expand Down Expand Up @@ -116,10 +117,10 @@ lazy val loggingStr = project
lazy val loggingDer = project
.in(file("modules/logging/derivation"))
.dependsOn(loggingStr)
.dependsOn(opticsMacro % "compile->test", derivation % "compile->test")
.dependsOn(derivation % "compile->test")
.settings(
defaultSettings,
libraryDependencies ++= Seq(derevo, magnolia, slf4j),
libraryDependencies ++= Seq(derevo, magnolia, slf4j, glassMacro % Test),
name := "tofu-logging-derivation"
)

Expand Down Expand Up @@ -207,52 +208,23 @@ lazy val observable = project
lazy val concurrent =
project
.in(file("modules/concurrent"))
.dependsOn(core, derivation % "compile->test", opticsMacro % "compile->test")
.dependsOn(core, derivation % "compile->test")
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsEffect2, catsTagless),
libraryDependencies ++= Seq(simulacrum, derevoTagless).map(_ % Test),
libraryDependencies ++= Seq(simulacrum, derevoTagless, glassMacro).map(_ % Test),
name := "tofu-concurrent",
)

lazy val config = project
.in(file("modules/config"))
.dependsOn(core, opticsCore, concurrent)
.dependsOn(core, concurrent)
.settings(
defaultSettings,
libraryDependencies ++= Seq(typesafeConfig, magnolia, derevo),
libraryDependencies ++= Seq(typesafeConfig, magnolia, derevo, glassCore),
name := "tofu-config",
)

lazy val opticsCore = project
.in(file("modules/optics/core"))
.settings(
defaultSettings,
libraryDependencies ++= Seq(catsCore, alleycats),
name := "tofu-optics-core"
)
.dependsOn(higherKindCore)

lazy val opticsInterop = project
.in(file("modules/optics/interop"))
.dependsOn(opticsCore)
.settings(defaultSettings, libraryDependencies ++= Vector(monocle, catsCore), name := "tofu-optics-interop")

lazy val opticsMacro = project
.in(file("modules/optics/macro"))
.dependsOn(opticsCore)
.settings(
defaultSettings,
scalacOptions ~= { opts =>
val suppressed = List(
"unused:params",
"unused:patvars"
)
opts.filterNot(opt => suppressed.exists(opt.contains))
},
name := "tofu-optics-macro"
)

lazy val enums = project
.in(file("modules/enums"))
.dependsOn(loggingStr)
Expand Down Expand Up @@ -300,20 +272,22 @@ lazy val zioInterop = project
lazy val fs2Interop = project
.in(file("modules/fs2"))
.settings(
name := "tofu-fs2-interop",
name := "tofu-fs2-interop",
libraryDependencies += fs2,
libraryDependencies += glassMacro % Test,
defaultSettings
)
.dependsOn(concurrent, streams)

lazy val fs2CE3Interop = project
.in(file("modules/fs2-ce3"))
.settings(
name := "tofu-fs2-ce3-interop",
name := "tofu-fs2-ce3-interop",
libraryDependencies += fs2CE3,
libraryDependencies += glassMacro % Test,
defaultSettings
)
.dependsOn(core3, streams, derivation % "compile->test", opticsMacro % "compile->test")
.dependsOn(core3, streams, derivation % "compile->test")

lazy val doobie = project
.in(file("modules/doobie/core"))
Expand Down Expand Up @@ -385,12 +359,10 @@ lazy val coreModules =
kernel,
kernelCE2Interop,
core,
opticsMacro,
memo,
derivation,
env,
concurrent,
opticsCore,
streams,
kernelCatsMtlInterop
)
Expand All @@ -401,7 +373,7 @@ lazy val ce3CoreModules = Vector(
)

lazy val commonModules =
Vector(observable, opticsInterop, logging, enums, config, zioInterop, fs2Interop, doobie, doobieLogging)
Vector(observable, logging, enums, config, zioInterop, fs2Interop, doobie, doobieLogging)

lazy val ce3CommonModules =
Vector(loggingStr, loggingDer, loggingLayout, doobieCE3, doobieLoggingCE3, fs2CE3Interop)
Expand All @@ -419,7 +391,7 @@ lazy val docs = project // new documentation project
addCompilerPlugin(simulacrum),
macros,
// ScalaUnidoc / doc / scalacOptions += "-Ymacro-expand:none",
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(allModuleRefs: _*) -- inProjects(opticsMacro),
ScalaUnidoc / unidoc / unidocProjectFilter := inProjects(allModuleRefs: _*),
ScalaUnidoc / unidoc / target := (LocalRootProject / baseDirectory).value / "website" / "static" / "api",
cleanFiles += (ScalaUnidoc / unidoc / target).value,
docusaurusCreateSite := docusaurusCreateSite.dependsOn(Compile / unidoc).value,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package tofu.concurrent

import cats._
import cats.effect._
import cats.tagless.InvariantK
import tofu.concurrent.impl._
import tofu.lift.{Rebase, Unlift}
import tofu.optics.Contains
import glass.Contains
import tofu.syntax.funk.{funK, funKFrom}
import tofu.syntax.monadic._
import tofu.{WithLocal, WithRun}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cats.effect.Bracket
import cats.effect.concurrent.{MVar, Ref}
import cats.syntax.functor._
import tofu.concurrent.Mut.FocusedMut
import tofu.optics.Contains
import glass.Contains
import tofu.syntax.bracket._

/** simplified form of synchonized mutable variable, that could be satisfied both by MVar and Ref */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu.concurrent.impl
import cats.Functor
import cats.data.State
import cats.effect.concurrent.Ref
import tofu.optics.Contains
import glass.Contains
import cats.syntax.functor._

/** Having A Contains B relation, make a ref that would change only marked part of state */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import cats.effect.concurrent.Ref
import cats.{Functor, Monad}
import tofu.BracketThrow
import tofu.concurrent.impl.FocusedRef
import tofu.optics.{Contains, PProperty}
import glass.{Contains, PProperty}
import tofu.syntax.monadic._

object ref {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import tofu.data.derived.ContextEmbed
import tofu.data.{ICalcM, Nothing2T}
import tofu.higherKind.derived.{embed, representableK}
import tofu.lift.{Rebase, Unlift}
import tofu.optics.macros.{ClassyOptics, GenContains, promote}
import glass.macros.{ClassyOptics, GenContains, promote}
import tofu.syntax.lift._
import tofu.syntax.monadic._
import tofu.syntax.raise._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cats.effect.concurrent.Ref
import cats.{Monad, Parallel}
import tofu.concurrent.ce2._
import tofu.config.ConfigTContext.Fail
import tofu.optics.Contains
import glass.Contains
import tofu.syntax.monadic._
import cats.MonadError
import cats.Applicative
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/tofu/ContextSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu

import cats.Applicative
import cats.data.ReaderT
import tofu.optics.Contains
import glass.Contains

object ContextSuite {
type Ctx >: Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.data.ReaderT
import cats.effect.IO
import org.scalatest.flatspec.AnyFlatSpec
import tofu.lift.UnliftSubcontext.FatApp
import tofu.optics.Contains
import glass.Contains
import UnliftSubcontext._
import cats.Monad
import org.scalatest.matchers.should.Matchers
Expand Down
2 changes: 1 addition & 1 deletion modules/core/src/test/scala/tofu/syntax/RetrySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import tofu.{ApplicativeThrow, Errors, Handle, Raise}
import tofu.syntax.handle._
import tofu.syntax.raise._
import cats.syntax.all._
import tofu.optics.Downcast
import glass.Downcast

class RetrySuite extends AnyFlatSpec {

Expand Down
2 changes: 1 addition & 1 deletion modules/core3/src/test/scala/tofu/ContextSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu

import cats.Applicative
import cats.data.ReaderT
import tofu.optics.Contains
import glass.Contains

object ContextSuite {
type Ctx >: Unit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.data.ReaderT
import cats.effect.IO
import org.scalatest.flatspec.AnyFlatSpec
import tofu.lift.UnliftSubcontext.FatApp
import tofu.optics.Contains
import glass.Contains
import UnliftSubcontext._
import cats.Monad
import org.scalatest.matchers.should.Matchers
Expand Down
2 changes: 1 addition & 1 deletion modules/core3/src/test/scala/tofu/syntax/RetrySuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import tofu.{ApplicativeThrow, Errors, Handle, Raise}
import tofu.syntax.handle._
import tofu.syntax.raise._
import cats.syntax.all._
import tofu.optics.Downcast
import glass.Downcast
import cats.effect.unsafe.IORuntime

class RetrySuite extends AnyFlatSpec {
Expand Down
2 changes: 1 addition & 1 deletion modules/env/src/main/scala/tofu/env/EnvInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import cats.{Applicative, Monad, Parallel, ~>}
import monix.eval.{Task, TaskLift}
import monix.execution.Scheduler
import tofu.lift.{UnliftIO, UnsafeExecFuture}
import tofu.optics.Contains
import glass.Contains
import tofu.syntax.funk._

import scala.concurrent.Future
Expand Down
2 changes: 1 addition & 1 deletion modules/env/src/main/scala/tofu/env/EnvUnliftTask.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu.env
import cats.~>
import monix.eval.Task
import tofu.lift.Unlift
import tofu.optics.Contains
import glass.Contains
import tofu.syntax.funk.funK

class EnvUnliftTask[E] extends Unlift[Task, Env[E, *]] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.data.ReaderT
import cats.effect.IO
import fs2.Stream
import tofu.WithContext
import tofu.optics.macros.{ClassyOptics, promote}
import glass.macros.{ClassyOptics, promote}
import scala.annotation.nowarn

object Fs2InteropContextAmbiguity {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.data.ReaderT
import cats.effect.IO
import fs2.Stream
import tofu.WithContext
import tofu.optics.macros.{ClassyOptics, promote}
import glass.macros.{ClassyOptics, promote}
import scala.annotation.nowarn

object Fs2InteropContextAmbiguity {
Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/Context.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package tofu
import cats.{Applicative, FlatMap, Functor, ~>}
import tofu.internal.ContextBase
import tofu.kernel.types._
import tofu.optics.{Contains, Equivalent, Extract}
import glass.{Contains, Equivalent, Extract}
import tofu.syntax.funk._

/** Declares that [[F]] can provide value of type Ctx
Expand Down
4 changes: 2 additions & 2 deletions modules/kernel/src/main/scala/tofu/Errors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import cats.{Applicative, ApplicativeError, FlatMap, Functor, Id, Monad}
import tofu.errorInstances._
import tofu.internal.{CachedMatcher, DataEffectComp}
import tofu.lift.Lift
import tofu.optics.PUpcast.GenericSubtypeImpl
import tofu.optics.{Downcast, Subset, Upcast}
import glass.PUpcast.GenericSubtypeImpl
import glass.{Downcast, Subset, Upcast}

import scala.annotation.implicitNotFound

Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/WithContext.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package tofu

import cats.{Applicative, FlatMap, Functor}
import tofu.optics.{Contains, Extract}
import glass.{Contains, Extract}

/** Synonym for [[Context]] with explicit C as Ctx for better type inference
*
Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/WithLocal.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package tofu

import tofu.optics.Contains
import glass.Contains

/** Synonym for [[Local]] with explicit C as Ctx for better type inference */
trait WithLocal[F[_], C] extends Local[F] with WithContext[F, C] {
Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/WithProvide.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu

import cats.~>
import tofu.lift.Lift
import tofu.optics.Extract
import glass.Extract
import tofu.syntax.funk.funK

/** Synonym for [[Provide]] with explicit `C` as `Ctx` and `G` as `Lower` for better type inference
Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/WithRun.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu

import cats.~>
import tofu.lift.Unlift
import tofu.optics.Equivalent
import glass.Equivalent
import tofu.syntax.funk.funK

/** Synonym for both [[RunContext]] and [[Unlift]] with explicit `C` as `Ctx` and `G` as `Lower` for better type
Expand Down
4 changes: 2 additions & 2 deletions modules/kernel/src/main/scala/tofu/bi/BiContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cats.Bifunctor
import tofu.bi.lift.BiUnlift
import tofu.control.Bind
import tofu.higherKind.bi.FunBK
import tofu.optics.{Contains, Equivalent, PExtract, Same}
import glass.{Contains, Equivalent, PExtract, Same}

/** typeclass for access a functional environment in a bifuntor
* @tparam X
Expand Down Expand Up @@ -207,7 +207,7 @@ class BiLocalSubInstance[F[+_, +_], X, C, E, A](ctx: BiLocal[F, X, C], lcts: Con
override def bilocal[E1, A1](fea: F[E1, A1])(lproj: E => E, rproj: A => A): F[E1, A1] =
ctx.bilocal(fea)(lcts.update(_, lproj), rcts.update(_, rproj))

override def sub[E1, A1](err: tofu.optics.Contains[E, E1], res: tofu.optics.Contains[A, A1]): BiLocal[F, E1, A1] =
override def sub[E1, A1](err: glass.Contains[E, E1], res: glass.Contains[A, A1]): BiLocal[F, E1, A1] =
ctx.sub(lcts >> err, rcts >> res)
}

Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/concurrent/Atom.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu.concurrent
import cats.{Applicative, Functor}

import tofu.higherKind.{RepresentableK, derived}
import tofu.optics.Contains
import glass.Contains
import tofu.syntax.monadic._
import cats.data.StateT
import tofu.data.calc.CalcM
Expand Down
2 changes: 1 addition & 1 deletion modules/kernel/src/main/scala/tofu/data/Calc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tofu.data

import cats.data.IndexedState
import cats.{MonadError, Monoid, StackSafeMonad}
import tofu.optics.PContains
import glass.PContains

import scala.annotation.tailrec
import tofu.Guarantee
Expand Down
Loading

0 comments on commit 55d8e87

Please sign in to comment.