diff --git a/.scalafmt.conf b/.scalafmt.conf new file mode 100644 index 0000000..7a07219 --- /dev/null +++ b/.scalafmt.conf @@ -0,0 +1,3 @@ +version = 2.7.3 +maxColumn = 100 +continuationIndent.defnSite = 2 diff --git a/modules/cats-effect/src/main/scala/make/ce/resource.scala b/modules/cats-effect/src/main/scala/make/ce/resource.scala index 11991a2..b5cc721 100644 --- a/modules/cats-effect/src/main/scala/make/ce/resource.scala +++ b/modules/cats-effect/src/main/scala/make/ce/resource.scala @@ -11,8 +11,8 @@ object resource { implicit def ceResourceEff[F[_]: Applicative]: MakeEff[Resource[F, ?]] = new MakeEff[Resource[F, ?]] { - def map[A, B](fa: Resource[F, A])(f: A => B): Resource[F, B] = fa.map(f) + def map[A, B](fa: Resource[F, A])(f: A => B): Resource[F, B] = fa.map(f) def pure[A](a: A): Resource[F, A] = Resource.pure(a) def flatMap[A, B](fa: Resource[F, A])(f: A => Resource[F, B]): Resource[F, B] = fa.flatMap(f) } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/Conflicts.scala b/modules/core/src/main/scala/make/Conflicts.scala index 954bb35..6a9891c 100644 --- a/modules/core/src/main/scala/make/Conflicts.scala +++ b/modules/core/src/main/scala/make/Conflicts.scala @@ -12,4 +12,4 @@ final case class Conflicts(values: List[Conflicts.TpeConflict]) extends Exceptio } object Conflicts { final case class TpeConflict(tpe: Type, positions: List[SourcePos]) -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/Graph.scala b/modules/core/src/main/scala/make/Graph.scala index a4472a8..9bdbe87 100644 --- a/modules/core/src/main/scala/make/Graph.scala +++ b/modules/core/src/main/scala/make/Graph.scala @@ -18,7 +18,7 @@ final class Graph[F[_], A]( val order = initOrder val init = F.pure(Map.empty[Type, Any]) - val rs = order.foldLeft(init){ case (rs, tpe) => + val rs = order.foldLeft(init) { case (rs, tpe) => MakeEff[F].flatMap(rs)(depsMap => { val entry = entries(tpe) @@ -27,22 +27,24 @@ final class Graph[F[_], A]( F.map(rsc)(v => depsMap.updated(tpe, v)) }) } - + MakeEff[F].map(rs)(values => values(targetTpe).asInstanceOf[A]) } private def initOrder: List[Type] = { val indexedKeys = entries.keys.zipWithIndex.toMap - val indexedMap = indexedKeys.map {case (tpe, _) => + val indexedMap = indexedKeys.map { case (tpe, _) => val entry = entries(tpe) entry.dependsOn.map(indexedKeys(_)).toList }.toList val sorted = Tarjans.apply(indexedMap) - sorted.flatten.map(i => { - val (tpe, idx) = indexedKeys.find(_._2 == i).get - tpe - }).toList + sorted.flatten + .map(i => { + val (tpe, idx) = indexedKeys.find(_._2 == i).get + tpe + }) + .toList } } @@ -53,7 +55,7 @@ object Graph { tpe: Type, pos: Tag.SourcePos, dependsOn: List[Type], - f: List[Any] => F[Any] + f: List[Any] => F[Any] ) def fromMake[F[_]: MakeEff, A](v: Make[F, A]): Either[Conflicts, Graph[F, A]] = { @@ -64,23 +66,22 @@ object Graph { val init = (Map.empty[Type, RawEntry[F]], List.empty[Conflicts.TpeConflict]) val (okMap, errors) = - allEntriesMap.foldLeft(init){ - case ((okAcc, errAcc), (tpe, entries)) => - val refs = entries.foldLeft(Set.empty[SourcePos]){case (acc, e) => acc + e.pos } - if (refs.size > 1) { - val error = Conflicts.TpeConflict(tpe, refs.toList) - (okAcc, error :: errAcc) - } else { - val nextOk = okAcc.updated(tpe, entries.head) - (nextOk, errAcc) - } + allEntriesMap.foldLeft(init) { case ((okAcc, errAcc), (tpe, entries)) => + val refs = entries.foldLeft(Set.empty[SourcePos]) { case (acc, e) => acc + e.pos } + if (refs.size > 1) { + val error = Conflicts.TpeConflict(tpe, refs.toList) + (okAcc, error :: errAcc) + } else { + val nextOk = okAcc.updated(tpe, entries.head) + (nextOk, errAcc) + } } - + if (errors.size > 0) { Left(Conflicts(errors)) } else { Right(new Graph(okMap, v.tag.typeTag.tpe)) - } + } } @tailrec @@ -92,7 +93,7 @@ object Graph { type HandleOut = (List[Any] => F[Any], List[Type], List[Make[F, Any]]) def handleNode(v: Make[F, Any]): HandleOut = v match { - case Make.Value(v, tag) => + case Make.Value(v, tag) => ((_: List[Any]) => v, List.empty, List.empty) case Make.Bind(prev, f, tag) => val func = (in: List[Any]) => f(in(0)) @@ -100,7 +101,7 @@ object Graph { val other = List(prev) (func, deps, other) case Make.Ap(prev, op, tag) => - val func = + val func = (in: List[Any]) => { val a = in(0) val aToB = in(1).asInstanceOf[Any => Any] @@ -142,4 +143,4 @@ object Graph { makeToAllEntriesMap(nextAcc, nextStack) } } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/Make.scala b/modules/core/src/main/scala/make/Make.scala index c277a2a..6549f4f 100644 --- a/modules/core/src/main/scala/make/Make.scala +++ b/modules/core/src/main/scala/make/Make.scala @@ -34,9 +34,10 @@ object Make extends MakeTupleInstances with LowPrioMake { def eff[F[_]: MakeEff, A: Tag](v: F[A]): Make[F, A] = Value(v, Tag.of[A]) - - implicit def contraMakeInstance[F[_]: MakeEff, B, A]( - implicit contra: ContraMake[B, A], m: Make[F, B], tag: Tag[A] + implicit def contraMakeInstance[F[_]: MakeEff, B, A](implicit + contra: ContraMake[B, A], + m: Make[F, B], + tag: Tag[A] ): Make[F, A] = MakeOps.map(m)(contra.f) } @@ -46,7 +47,6 @@ object ContraMake { def apply[B, A](f: B => A): ContraMake[B, A] = new ContraMake[B, A](f) } - trait LowPrioMake { implicit def debugInstance[F[_], A](implicit x: Debug[Make[F, A]]): Make[F, A] = x.v -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/MakeEff.scala b/modules/core/src/main/scala/make/MakeEff.scala index 095f69a..9732631 100644 --- a/modules/core/src/main/scala/make/MakeEff.scala +++ b/modules/core/src/main/scala/make/MakeEff.scala @@ -8,4 +8,4 @@ trait MakeEff[F[_]] { object MakeEff { def apply[F[_]](implicit eff: MakeEff[F]): MakeEff[F] = eff -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/MakeSyntax.scala b/modules/core/src/main/scala/make/MakeSyntax.scala index f599116..fb2e6d8 100644 --- a/modules/core/src/main/scala/make/MakeSyntax.scala +++ b/modules/core/src/main/scala/make/MakeSyntax.scala @@ -27,4 +27,4 @@ final class MakeBasicSyntax[F[_], A](private val m: Make[F, A]) extends AnyVal { // case Right(dag) => dag.toEff // } // } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/Tag.scala b/modules/core/src/main/scala/make/Tag.scala index e5d0b20..9f77467 100644 --- a/modules/core/src/main/scala/make/Tag.scala +++ b/modules/core/src/main/scala/make/Tag.scala @@ -20,4 +20,4 @@ object Tag { implicit def materialize: SourcePos = macro SourcePosMacro.materializeSourcePos } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/autoMake.scala b/modules/core/src/main/scala/make/autoMake.scala index 05592bd..960f318 100644 --- a/modules/core/src/main/scala/make/autoMake.scala +++ b/modules/core/src/main/scala/make/autoMake.scala @@ -7,4 +7,4 @@ import scala.annotation.compileTimeOnly class autoMake extends StaticAnnotation { def macroTransform(annottees: Any*): Any = macro MakeAnnotationMacro.autoMake -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/enableDebug.scala b/modules/core/src/main/scala/make/enableDebug.scala index 135e433..d3f3f52 100644 --- a/modules/core/src/main/scala/make/enableDebug.scala +++ b/modules/core/src/main/scala/make/enableDebug.scala @@ -3,10 +3,10 @@ package make import make.internal.MakeMacro object enableDebug { - implicit def makeToDebugSyntax(obj: Make.type): DebugSyntax = new DebugSyntax(obj) - implicit def debugHook[F[_], A]: Debug[Make[F, A]] = macro MakeMacro.debugHook[F, A] + implicit def makeToDebugSyntax(obj: Make.type): DebugSyntax = new DebugSyntax(obj) + implicit def debugHook[F[_], A]: Debug[Make[F, A]] = macro MakeMacro.debugHook[F, A] } final class DebugSyntax(val obj: Make.type) extends AnyVal { def debugOf[F[_], A]: Make[F, A] = macro MakeMacro.debug[F, A] -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/internal/MacroState.scala b/modules/core/src/main/scala/make/internal/MacroState.scala index 19f06d6..70fc072 100644 --- a/modules/core/src/main/scala/make/internal/MacroState.scala +++ b/modules/core/src/main/scala/make/internal/MacroState.scala @@ -10,14 +10,14 @@ private[make] object MacroState { private class MacroStateAttachment(val state: collection.mutable.HashMap[Class[_], Any]) /** - * Associates some state with a global.Run. Preferable to using static state in the macro - * classloader (e.g vars in top level objects) so as to avoid race conditions under `-Ycache-macro-classloader`. - * - * @tparam T the type of the state. The erased `Class[_]` value for this type will be used a a map key, so each user of - * this facility should use a dedicated and distinct class to wrap the state. - * @param u The reflection universe, typically obtained from `context.universe` in a macro implementation. - * @param factory Factory to create the state. - */ + * Associates some state with a global.Run. Preferable to using static state in the macro + * classloader (e.g vars in top level objects) so as to avoid race conditions under `-Ycache-macro-classloader`. + * + * @tparam T the type of the state. The erased `Class[_]` value for this type will be used a a map key, so each user of + * this facility should use a dedicated and distinct class to wrap the state. + * @param u The reflection universe, typically obtained from `context.universe` in a macro implementation. + * @param factory Factory to create the state. + */ def getOrElseUpdate[T: ClassTag](u: Universe, factory: => T): T = { // Cast needed for access to perRunCaches and convenient access to attachments val g = u.asInstanceOf[scala.reflect.internal.SymbolTable] @@ -47,4 +47,4 @@ private[make] object MacroState { value } } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/internal/MakeAnnotationMacro.scala b/modules/core/src/main/scala/make/internal/MakeAnnotationMacro.scala index 1463833..f2adca7 100644 --- a/modules/core/src/main/scala/make/internal/MakeAnnotationMacro.scala +++ b/modules/core/src/main/scala/make/internal/MakeAnnotationMacro.scala @@ -10,31 +10,31 @@ class MakeAnnotationMacro(val c: blackbox.Context) { def autoMake(annottees: Tree*): Tree = { annottees match { case List(cls: ClassDef) => - Clz.extract(cls) match { - case Some(clz) => + Clz.extract(cls) match { + case Some(clz) => q""" $cls object ${cls.name.toTermName} { ${instanceTree(clz)} } - """ - case None => reportUnexpectedError() - } + """ + case None => reportUnexpectedError() + } case List( - cls: ClassDef, - q"..$mods object $objName extends { ..$objEarlyDefs } with ..$objParents { $objSelf => ..$objDefs }" - ) => - Clz.extract(cls) match { - case Some(clz) => - q""" + cls: ClassDef, + q"..$mods object $objName extends { ..$objEarlyDefs } with ..$objParents { $objSelf => ..$objDefs }" + ) => + Clz.extract(cls) match { + case Some(clz) => + q""" $cls $mods object $objName extends { ..$objEarlyDefs } with ..$objParents { $objSelf => ..$objDefs ..${instanceTree(clz)} } - """ - case None => reportUnexpectedError() - } + """ + case None => reportUnexpectedError() + } case _ => c.abort(c.enclosingPosition, "@deriveMake can be applied only on case classes or classes") } @@ -53,8 +53,8 @@ class MakeAnnotationMacro(val c: blackbox.Context) { val mapF = if (params.size > 1) q"($create).tupled" else create val effTpe = TermName(c.freshName("E")).toTypeName - - val targetTpe = + + val targetTpe = if (typeParams.isEmpty) tq"${name.toTypeName}" else @@ -62,10 +62,10 @@ class MakeAnnotationMacro(val c: blackbox.Context) { val implicits = q"deps: _root_.make.Make[$effTpe, $tpe]" :: - q"${TermName(c.freshName())}: _root_.make.MakeEff[$effTpe]" :: - implicitParams.toList ++ - (if (paramsTpe.isEmpty) List.empty else List(q"tag: _root_.make.Tag[$targetTpe]")) - + q"${TermName(c.freshName())}: _root_.make.MakeEff[$effTpe]" :: + implicitParams.toList ++ + (if (paramsTpe.isEmpty) List.empty else List(q"tag: _root_.make.Tag[$targetTpe]")) + q""" implicit def make[$effTpe[_], ..$typeParams]( implicit ..${implicits} @@ -85,27 +85,35 @@ class MakeAnnotationMacro(val c: blackbox.Context) { object Clz { def extract(clsDef: ClassDef): Option[Clz] = { - findInit(clsDef.impl.body).map{ init => - val tparams = clsDef.tparams - val (params, implicitParams) = - init.vparamss.flatten.foldLeft((Vector.empty[ValDef], Vector.empty[ValDef])){ - case ((pAcc, ipAcc), vdef) => - val isImplicit = vdef.mods.hasFlag(Flag.IMPLICIT) - if (isImplicit) - (pAcc, ipAcc :+ vdef) - else - (pAcc :+ vdef, ipAcc) - } - - val create = { - val funValDefs = params.zipWithIndex.map({ - case (d, i) => ValDef(Modifiers(Flag.PARAM), TermName(s"x$i"), d.tpt, EmptyTree) - }).toList - Function(funValDefs, Apply(Select(New(Ident(clsDef.name.decodedName)), init.name), funValDefs.map(d => Ident(d.name)))) + findInit(clsDef.impl.body).map { init => + val tparams = clsDef.tparams + val (params, implicitParams) = + init.vparamss.flatten.foldLeft((Vector.empty[ValDef], Vector.empty[ValDef])) { + case ((pAcc, ipAcc), vdef) => + val isImplicit = vdef.mods.hasFlag(Flag.IMPLICIT) + if (isImplicit) + (pAcc, ipAcc :+ vdef) + else + (pAcc :+ vdef, ipAcc) } - Clz(clsDef.name, tparams, params.toList, implicitParams.toList, create) + val create = { + val funValDefs = params.zipWithIndex + .map({ case (d, i) => + ValDef(Modifiers(Flag.PARAM), TermName(s"x$i"), d.tpt, EmptyTree) + }) + .toList + Function( + funValDefs, + Apply( + Select(New(Ident(clsDef.name.decodedName)), init.name), + funValDefs.map(d => Ident(d.name)) + ) + ) } + + Clz(clsDef.name, tparams, params.toList, implicitParams.toList, create) + } } def findInit(body: List[Tree]): Option[DefDef] = @@ -114,4 +122,4 @@ class MakeAnnotationMacro(val c: blackbox.Context) { } } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/internal/MakeBasicOps.scala b/modules/core/src/main/scala/make/internal/MakeBasicOps.scala index 60765c5..c3418d1 100644 --- a/modules/core/src/main/scala/make/internal/MakeBasicOps.scala +++ b/modules/core/src/main/scala/make/internal/MakeBasicOps.scala @@ -16,7 +16,7 @@ trait MakeBasicOps { def mapF[F[_]: MakeEff, A, B: Tag](ma: Make[F, A])(f: A => F[B]): Make[F, B] = Make.Bind( ma, - (a: A) => f(a), + (a: A) => f(a), Tag.of[B] ) @@ -27,4 +27,4 @@ trait MakeBasicOps { Tag.of[B] ) -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/internal/MakeMacro.scala b/modules/core/src/main/scala/make/internal/MakeMacro.scala index e28ce40..27a79e6 100644 --- a/modules/core/src/main/scala/make/internal/MakeMacro.scala +++ b/modules/core/src/main/scala/make/internal/MakeMacro.scala @@ -12,10 +12,11 @@ class MakeMacro(val c: whitebox.Context) { val state = MacroState.getOrElseUpdate[DebugSt](c.universe, new DebugSt) val debugInstanceFullName = "make.LowPrioMake.debugInstance" - val debugHookFullName = "make.enableDebug.debugHook" + val debugHookFullName = "make.enableDebug.debugHook" - def debug[F[_], A]( - implicit ftpe: WeakTypeTag[F[X] forSome {type X}], atpe: WeakTypeTag[A] + def debug[F[_], A](implicit + ftpe: WeakTypeTag[F[X] forSome { type X }], + atpe: WeakTypeTag[A] ): c.Expr[Make[F, A]] = { val makeTc = weakTypeOf[Make[F, _]].typeConstructor @@ -29,18 +30,18 @@ class MakeMacro(val c: whitebox.Context) { val st = extractInstanceSt(atpe.tpe, state.reverseTraces) val message = renderInstanceSt(st) c.abort(c.enclosingPosition, s"Make for ${atpe.tpe} not found\n" + message) - case tree => + case tree => val message = s"Debug: OK!\n\tMake instance for ${atpe.tpe} exists.\n\nRemove debug usage." c.info(c.enclosingPosition, message, true) c.Expr[Make[F, A]](tree) } } - def debugHook[F[_], A]( - implicit ftpe: WeakTypeTag[F[X] forSome {type X}], atpe: WeakTypeTag[A] + def debugHook[F[_], A](implicit + ftpe: WeakTypeTag[F[X] forSome { type X }], + atpe: WeakTypeTag[A] ): c.Expr[Debug[Make[F, A]]] = { - if (!state.debug) c.abort(c.enclosingPosition, "debug is not enabled") val makeTc = weakTypeOf[Make[F, _]].typeConstructor @@ -53,7 +54,7 @@ class MakeMacro(val c: whitebox.Context) { } else { false } - + if (isSelfLoop) { c.abort(c.enclosingPosition, "skip") } else { @@ -63,7 +64,7 @@ class MakeMacro(val c: whitebox.Context) { val defaultInstance = c.inferImplicitValue(makeTpe) defaultInstance match { case EmptyTree => - trace.path.headOption.foreach{ v => + trace.path.headOption.foreach { v => val symSt = state.reverseTraces.getOrElse(v.tpe, mutable.HashMap.empty) symSt.update(v.sym, atpe.tpe) state.reverseTraces.update(v.tpe, symSt) @@ -78,10 +79,11 @@ class MakeMacro(val c: whitebox.Context) { private def resolutionTrace( openImplicits: List[c.ImplicitCandidate], - makeTc: c.Type + makeTc: c.Type ): Trace = { - val filtered = openImplicits.filter(c => !isDebugCandidate(c)) - .flatMap{c => + val filtered = openImplicits + .filter(c => !isDebugCandidate(c)) + .flatMap { c => val dealiased = c.pt.dealias val tc = dealiased.typeConstructor if (tc =:= makeTc) { @@ -90,7 +92,7 @@ class MakeMacro(val c: whitebox.Context) { } else { None } - } + } Trace(filtered) } @@ -106,9 +108,9 @@ class MakeMacro(val c: whitebox.Context) { reverseTraces.get(targetType) match { case None => InstanceSt.NoInstances(targetType) case Some(paths) => - val traces = paths.map{ case (sym, tpe) => - val depSt = extractInstanceSt(tpe, reverseTraces) - InstanceSt.FailedTrace(sym, tpe, depSt) + val traces = paths.map { case (sym, tpe) => + val depSt = extractInstanceSt(tpe, reverseTraces) + InstanceSt.FailedTrace(sym, tpe, depSt) } InstanceSt.FailedTraces(targetType, traces.toList) } @@ -124,14 +126,14 @@ class MakeMacro(val c: whitebox.Context) { case InstanceSt.NoInstances(_) => sb.append(s"\n${appendTabs}Make instance for ${st.tpe} not found") case InstanceSt.FailedTraces(_, traces) => - traces.foldLeft(sb){case (sb, trace) => + traces.foldLeft(sb) { case (sb, trace) => val next = sb.append(s"\n${appendTabs}Failed at ${trace.sym.fullName} becase of:") render(next, level + 1, trace.dependencySt) } } } - - render(new StringBuilder, 1 , st).toString + + render(new StringBuilder, 1, st).toString } sealed trait InstanceSt { @@ -145,15 +147,16 @@ class MakeMacro(val c: whitebox.Context) { dependencyTpe: Type, dependencySt: InstanceSt ) - + case class FailedTraces(tpe: Type, traces: List[FailedTrace]) extends InstanceSt } case class Part(tpe: c.Type, sym: Symbol) case class Trace(path: List[Part]) - + class DebugSt( var debug: Boolean = false, - val reverseTraces: mutable.HashMap[Type, mutable.HashMap[c.Symbol, c.Type]] = mutable.HashMap.empty + val reverseTraces: mutable.HashMap[Type, mutable.HashMap[c.Symbol, c.Type]] = + mutable.HashMap.empty ) -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/internal/MakeOps.scala b/modules/core/src/main/scala/make/internal/MakeOps.scala index 35c388b..4f85863 100644 --- a/modules/core/src/main/scala/make/internal/MakeOps.scala +++ b/modules/core/src/main/scala/make/internal/MakeOps.scala @@ -1,4 +1,4 @@ package make.internal trait MakeOps extends MakeProductNOps -object MakeOps extends MakeOps \ No newline at end of file +object MakeOps extends MakeOps diff --git a/modules/core/src/main/scala/make/internal/SourcePosMacro.scala b/modules/core/src/main/scala/make/internal/SourcePosMacro.scala index 3131736..e05bada 100644 --- a/modules/core/src/main/scala/make/internal/SourcePosMacro.scala +++ b/modules/core/src/main/scala/make/internal/SourcePosMacro.scala @@ -16,4 +16,4 @@ class SourcePosMacro(val c: blackbox.Context) { c.Expr[SourcePos](tree) } -} \ No newline at end of file +} diff --git a/modules/core/src/main/scala/make/internal/Tarjans.scala b/modules/core/src/main/scala/make/internal/Tarjans.scala index 7cc13b4..de1117c 100644 --- a/modules/core/src/main/scala/make/internal/Tarjans.scala +++ b/modules/core/src/main/scala/make/internal/Tarjans.scala @@ -12,12 +12,11 @@ object Tarjans { var time = 0 val lowlink = new Array[Int](n) val components = mutable.ArrayBuffer.empty[Seq[Int]] - - + for (u <- 0 until n) { if (!visited(u)) dfs(u) } - + def dfs(u: Int): Unit = { lowlink(u) = time time += 1 @@ -33,7 +32,7 @@ object Tarjans { } if (isComponentRoot) { val component = mutable.Buffer.empty[Int] - + var done = false while (!done) { val x = stack.last @@ -48,4 +47,3 @@ object Tarjans { components.toSeq } } - diff --git a/modules/core/src/test/scala/make/MakeTest.scala b/modules/core/src/test/scala/make/MakeTest.scala index 00336a1..7576adf 100644 --- a/modules/core/src/test/scala/make/MakeTest.scala +++ b/modules/core/src/test/scala/make/MakeTest.scala @@ -27,5 +27,5 @@ class MakeTest extends FunSuite { assert(a.toGraph.isRight) assert(b.toGraph.isLeft) } - -} \ No newline at end of file + +} diff --git a/modules/core/src/test/scala/make/ioEff.scala b/modules/core/src/test/scala/make/ioEff.scala index 6535957..413d6c0 100644 --- a/modules/core/src/test/scala/make/ioEff.scala +++ b/modules/core/src/test/scala/make/ioEff.scala @@ -10,4 +10,4 @@ object ioEff { def pure[A](a: A): IO[A] = IO.pure(a) def flatMap[A, B](fa: IO[A])(f: A => IO[B]): IO[B] = fa.flatMap(f) } -} \ No newline at end of file +} diff --git a/modules/core/src/test/scala/make/itCompiles.scala b/modules/core/src/test/scala/make/itCompiles.scala index b31cc4e..22f93ea 100644 --- a/modules/core/src/test/scala/make/itCompiles.scala +++ b/modules/core/src/test/scala/make/itCompiles.scala @@ -69,4 +69,4 @@ object itCompiles { } } -} \ No newline at end of file +} diff --git a/modules/example/src/main/scala/example/ExampleCatsEffect.scala b/modules/example/src/main/scala/example/ExampleCatsEffect.scala index fbbc63e..d52371b 100644 --- a/modules/example/src/main/scala/example/ExampleCatsEffect.scala +++ b/modules/example/src/main/scala/example/ExampleCatsEffect.scala @@ -49,10 +49,10 @@ object ExampleCatsEffect extends IOApp { val make = Make.debugOf[IOResource, End] for { - graph <- IO.fromEither(make.toGraph) - resource = graph.initEff - _ <- resource.use(end => IO(println(end))) + graph <- IO.fromEither(make.toGraph) + resource = graph.initEff + _ <- resource.use(end => IO(println(end))) } yield ExitCode.Success } -} \ No newline at end of file +} diff --git a/modules/example/src/main/scala/example/ExampleZio.scala b/modules/example/src/main/scala/example/ExampleZio.scala index 0ae2593..0b9d47e 100644 --- a/modules/example/src/main/scala/example/ExampleZio.scala +++ b/modules/example/src/main/scala/example/ExampleZio.scala @@ -32,18 +32,18 @@ object ExampleZio extends App { @autoMake class End(yo: Yohoho, yo2: Yohoho2) - override def run(args: List[String]): URIO[ZEnv,ExitCode] = { + override def run(args: List[String]): URIO[ZEnv, ExitCode] = { - // For ZIO it's required to define MakeEff TC manually to specify R, E + // For ZIO it's required to define MakeEff TC manually to specify R, E type MakeZManaged[A] = ZManaged[Console, Nothing, A] implicit val zmanagedEff = new MakeEff[MakeZManaged] { def map[A, B](fa: MakeZManaged[A])(f: A => B): MakeZManaged[B] = fa.map(f) def pure[A](a: A): MakeZManaged[A] = ZManaged.effectTotal(a) - def flatMap[A, B](fa: MakeZManaged[A])(f: A => MakeZManaged[B]): MakeZManaged[B] = fa.flatMap(f) + def flatMap[A, B](fa: MakeZManaged[A])(f: A => MakeZManaged[B]): MakeZManaged[B] = + fa.flatMap(f) } - implicit val depImplAsDep = ContraMake.widen[DepImpl, Dep] implicit val initString = Make.eff[MakeZManaged, String]( ZManaged.make(putStrLn("Yoyo") *> ZIO.effectTotal("asd"))(_ => putStrLn("Close")) @@ -58,4 +58,4 @@ object ExampleZio extends App { _ <- zmanaged.use(r => putStrLn(r.toString)) } yield ExitCode.success } -} \ No newline at end of file +} diff --git a/project/plugins.sbt b/project/plugins.sbt index 7cffad4..4e15366 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("ch.epfl.lamp" % "sbt-dotty" % "0.4.1") \ No newline at end of file +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.0") \ No newline at end of file