Skip to content

Commit

Permalink
Update .scalafmt.conf
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Aug 27, 2024
1 parent 38aeebe commit 1a63e72
Show file tree
Hide file tree
Showing 45 changed files with 52 additions and 56 deletions.
10 changes: 3 additions & 7 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,10 @@ maxColumn = 120
continuationIndent.defnSite = 2
danglingParentheses.preset = true
rewrite.rules = [SortImports, RedundantBraces, RedundantParens, SortModifiers]
runner.dialect = Scala213
fileOverride {
"glob:**/src/**/scala-3/**" {
runner.dialect = scala3
rewrite.scala3.convertToNewSyntax = false
}
}
runner.dialect = Scala213Source3
project.layout = StandardConvention
rewrite.scala3.convertToNewSyntax = true
rewrite.scala3.newSyntax.control = false
runner.dialectOverride.allowSignificantIndentation = false
runner.dialectOverride.allowAsForImportRename = false
runner.dialectOverride.allowStarWildcardImport = false
2 changes: 1 addition & 1 deletion bench/src/main/scala/monocle/bench/BenchModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ object BenchModel {
case class Point3(x: Int, y: Int, z: Int)
val p = Point3(2, 10, 24)

val map = SortedMap(1.to(200).map(_ -> 5) *)
val map = SortedMap(1.to(200).map(_ -> 5)*)

case class IntWrapper0(i: Int)
case class IntWrapper1(i: Int)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ private[monocle] object AppliedFocusImpl {
Quotes
): Expr[Any] = {

import quotes.reflect._
import quotes.reflect.*

val generatedOptic = FocusImpl(lambda)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private[monocle] object ComposedFocusImpl {
optic: Expr[AnyOptic[S, A]],
lambda: Expr[Focus.KeywordContext ?=> A => Next]
)(using Quotes): Expr[Any] = {
import quotes.reflect._
import quotes.reflect.*

val generatedOptic = FocusImpl(lambda).asTerm
val opticType = optic.asTerm.tpe.widen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private[focus] class FocusImpl(val macroContext: Quotes)
with GeneratorLoop
with AllFeatureGenerators {

import macroContext.reflect._
import macroContext.reflect.*

def run[From: Type, To: Type](lambda: Expr[Focus.KeywordContext ?=> From => To]): Expr[Any] = {
val generatedCode =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import scala.quoted.Type
private[focus] trait LambdaConfigParser {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def parseLambdaConfig[From: Type](lambda: Term): FocusResult[LambdaConfig] = {
val fromType = TypeRepr.of[From]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private[focus] trait AllFeatureGenerators
private[focus] trait GeneratorLoop {
this: AllFeatureGenerators =>

import macroContext.reflect._
import macroContext.reflect.*

def generateCode[From: Type](actions: List[FocusAction]): FocusResult[Term] = {
val idOptic: FocusResult[Term] = Right('{ Iso.id[From] }.asTerm)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.FocusBase
private[focus] trait KeywordParserBase extends ParserBase {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

// Marker classes for type safety
case class Name(name: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.FocusBase
private[focus] trait ParserBase {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

// Marker class for type safety
case class RemainingCode(code: Term)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private[focus] trait AllFeatureParsers
private[focus] trait ParserLoop {
this: AllFeatureParsers =>

import macroContext.reflect._
import macroContext.reflect.*

def parseFocusActions(config: LambdaConfig): FocusResult[List[FocusAction]] = {
def loop(remainingBody: RemainingCode, listSoFar: List[FocusAction]): FocusResult[List[FocusAction]] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import monocle.internal.focus.FocusBase
private[focus] trait SelectParserBase extends ParserBase {
this: FocusBase =>

import this.macroContext.reflect._
import this.macroContext.reflect.*

// Match on a term that is an instance of a case class
object CaseClass {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.AsPrismImpl
private[focus] trait AsGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateAs(action: FocusAction.KeywordAs): Term = {
import action.{fromType, toType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.FocusBase
private[focus] trait AtGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateAt(action: FocusAction.KeywordAt): Term = {
import action.{fromType, toType, index, atInstance}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.FocusBase
private[focus] trait EachGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateEach(action: FocusAction.KeywordEach): Term = {
import action.{fromType, toType, eachInstance}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.FocusBase
private[focus] trait IndexGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateIndex(action: FocusAction.KeywordIndex): Term = {
import action.{fromType, toType, index, indexInstance}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scala.quoted.Quotes
private[focus] trait SelectFieldGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateSelectField(action: FocusAction.SelectField): Term = {
import action.{fieldName, fromType, fromTypeArgs, toType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.features.SelectParserBase
private[focus] trait SelectFieldParser {
this: FocusBase & SelectParserBase =>

import this.macroContext.reflect._
import this.macroContext.reflect.*

object SelectField extends FocusParser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import scala.quoted.Quotes
private[focus] trait SelectOnlyFieldGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateSelectOnlyField(action: FocusAction.SelectOnlyField): Term = {
import action.{fieldName, fromType, fromTypeArgs, fromCompanion, toType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.internal.focus.features.SelectParserBase
private[focus] trait SelectOnlyFieldParser {
this: FocusBase & SelectParserBase =>

import this.macroContext.reflect._
import this.macroContext.reflect.*

object SelectOnlyField extends FocusParser {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.std.option.some
private[focus] trait SomeGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateSome(action: FocusAction.KeywordSome): Term =
action.toType.asType match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import monocle.std.option.withDefault
private[focus] trait WithDefaultGenerator {
this: FocusBase =>

import macroContext.reflect._
import macroContext.reflect.*

def generateWithDefault(action: FocusAction.KeywordWithDefault): Term = {
import action.{toType, defaultValue}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package monocle.syntax

import monocle._
import monocle.*
import monocle.internal.focus.ComposedFocusImpl

trait ComposedFocusSyntax {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package monocle.syntax

import monocle._
import monocle.*
import monocle.internal.{AsPrism, IsoFields}
import scala.deriving.Mirror

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ object FilterIndex extends FilterIndexFunctions {
.traverse { case (k, v) =>
(if (predicate(k)) f(v) else v.pure[F]).tupleLeft(k)
}
.map(kvs => SortedMap(kvs *)(ok.toOrdering))
.map(kvs => SortedMap(kvs*)(ok.toOrdering))
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.focus

import monocle.Focus
import monocle.Focus._
import monocle.Focus.*

final class AppliedFocusTest extends munit.FunSuite {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.focus

import monocle._
import monocle.syntax.all._
import monocle.*
import monocle.syntax.all.*
import monocle.syntax.{AppliedGetter, AppliedSetter}

object ComposedFocusTest {
Expand All @@ -28,7 +28,7 @@ object ComposedFocusTest {

final class ComposedFocusTest extends munit.FunSuite {

import ComposedFocusTest._
import ComposedFocusTest.*

test("Lens refocus correctly composes Lens") {
val addressLens: Lens[User, Address] = Focus[User](_.address)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.focus

import monocle.Focus
import monocle.function.At._
import monocle.function.At.*

final class FocusAtTest extends munit.FunSuite {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package monocle.focus

import monocle.Focus
import monocle.function.Each._
import monocle.std.list._
import monocle.function.Each.*
import monocle.std.list.*

final class FocusEachTest extends munit.FunSuite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ final class FocusImportTest extends munit.FunSuite {
val user = User("Edith", Some(Address(45, "2120")))

test("import Focus object") {
import monocle.Focus._
import monocle.Focus.*
user.focus(_.address.some.streetNumber)
}

test("import all syntax") {
import monocle.syntax.all._
import monocle.syntax.all.*
user.focus(_.address.some.streetNumber)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.focus

import monocle.Focus
import monocle.function.Index._
import monocle.function.Index.*

final class FocusIndexTest extends munit.FunSuite {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.focus

import monocle.Focus
import monocle.Focus._
import monocle.Focus.*

final class FocusSomeTest extends munit.FunSuite {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.internal

import monocle.Iso
import monocle.syntax.all._
import monocle.syntax.all.*

final class IsoFieldsTest extends munit.FunSuite {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ object AtTests extends Laws {
evAt: At[S, I, A],
arbAA: Arbitrary[A => A]
): RuleSet =
new SimpleRuleSet("At", LensTests[S, A, I](at(_)).props *)
new SimpleRuleSet("At", LensTests[S, A, I](at(_)).props*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ object Cons1Tests extends Laws {
"Cons1",
(IsoTests(cons1[S, H, T]).props ++
LensTests(head[S, H, T]).props ++
LensTests(tail[S, H, T]).props) *
LensTests(tail[S, H, T]).props)*
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ object ConsTests extends Laws {
"Cons",
(PrismTests(cons[S, A]).props ++
OptionalTests(headOption[S, A]).props ++
OptionalTests(tailOption[S, A]).props) *
OptionalTests(tailOption[S, A]).props)*
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ import cats.Eq

object EachTests extends Laws {
def apply[S: Eq: Arbitrary, A: Eq: Arbitrary](implicit evEach: Each[S, A], arbAA: Arbitrary[A => A]): RuleSet =
new SimpleRuleSet("Each", TraversalTests(each[S, A]).props *)
new SimpleRuleSet("Each", TraversalTests(each[S, A]).props*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ object FilterIndexTests extends Laws {
arbAA: Arbitrary[A => A],
arbIB: Arbitrary[I => Boolean]
): RuleSet =
new SimpleRuleSet("FilterIndex", TraversalTests(filterIndex(_: I => Boolean)(evFilterIndex)).props *)
new SimpleRuleSet("FilterIndex", TraversalTests(filterIndex(_: I => Boolean)(evFilterIndex)).props*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ object IndexTests extends Laws {
evIndex: Index[S, I, A],
arbAA: Arbitrary[A => A]
): RuleSet =
new SimpleRuleSet("Index", OptionalTests(index(_: I)(evIndex)).props *)
new SimpleRuleSet("Index", OptionalTests(index(_: I)(evIndex)).props*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ object PossibleTests extends Laws {
evPossible: Possible[S, A],
arbAA: Arbitrary[A => A]
): RuleSet =
new SimpleRuleSet("Possible", OptionalTests(possible[S, A]).props *)
new SimpleRuleSet("Possible", OptionalTests(possible[S, A]).props*)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ object Snoc1Tests extends Laws {
"Snoc1",
(IsoTests(snoc1[S, I, L]).props ++
LensTests(init[S, I, L]).props ++
LensTests(last[S, I, L]).props) *
LensTests(last[S, I, L]).props)*
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ object SnocTests extends Laws {
"Snoc",
(PrismTests(snoc[S, A]).props ++
OptionalTests(lastOption[S, A]).props ++
OptionalTests(initOption[S, A]).props) *
OptionalTests(initOption[S, A]).props)*
)
}
2 changes: 1 addition & 1 deletion macro/src/main/scala-3/monocle/macros/GenPrism.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package monocle.macros

import monocle.{Focus, Prism}
import monocle.syntax.all._
import monocle.syntax.all.*

object GenPrism {
inline def apply[Source, Target <: Source]: Prism[Source, Target] =
Expand Down
2 changes: 1 addition & 1 deletion test/shared/src/test/scala/monocle/TestInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait TestInstances extends PlatformSpecificTestInstances with cats.instances.Al
Arbitrary(Arbitrary.arbitrary[List[A]].map(_.toVector))

implicit def listMapArbitrary[K: Arbitrary, V: Arbitrary]: Arbitrary[ListMap[K, V]] =
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(l => ListMap(l *)))
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(l => ListMap(l*)))

implicit def mapArbitrary[K: Arbitrary, V: Arbitrary]: Arbitrary[Map[K, V]] =
Arbitrary(Arbitrary.arbitrary[List[(K, V)]].map(_.toMap))
Expand Down
Loading

0 comments on commit 1a63e72

Please sign in to comment.