-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump Scala version/revise samples/add scalafmt (#118)
- Loading branch information
Showing
25 changed files
with
220 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
version = 3.7.2 | ||
runner.dialect = scala3 | ||
|
||
style = defaultWithAlign | ||
indentOperator.preset = akka | ||
maxColumn = 120 | ||
rewrite.rules = [RedundantParens, AvoidInfix] | ||
align.tokens = [{code = "=>", owner = "Case"}] | ||
align.openParenDefnSite = false | ||
align.openParenCallSite = false | ||
optIn.breakChainOnFirstMethodDot = false | ||
optIn.configStyleArguments = false | ||
danglingParentheses.defnSite = false | ||
danglingParentheses.callSite = false | ||
rewrite.neverInfix.excludeFilters = [ | ||
and | ||
min | ||
max | ||
until | ||
to | ||
by | ||
eq | ||
ne | ||
"should.*" | ||
"contain.*" | ||
"must.*" | ||
in | ||
ignore | ||
be | ||
taggedAs | ||
thrownBy | ||
synchronized | ||
have | ||
when | ||
size | ||
only | ||
noneOf | ||
oneElementOf | ||
noElementsOf | ||
atLeastOneElementOf | ||
atMostOneElementOf | ||
allElementsOf | ||
inOrderElementsOf | ||
theSameElementsAs | ||
message | ||
] | ||
rewriteTokens = { | ||
"⇒": "=>" | ||
"→": "->" | ||
"←": "<-" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
scalacOptions ++= Seq( | ||
"-source:3.0", | ||
) | ||
scalacOptions ++= Seq("-source:3.0") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
code-snippets/contextual-abstractions/src/main/scala/org/lunatech/dotty/using/Engine.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package org.lunatech.dotty.using | ||
|
||
final case class Engine(name: String) | ||
final case class Engine(name: String) |
2 changes: 1 addition & 1 deletion
2
...ippets/contextual-abstractions/src/main/scala/org/lunatech/dotty/using/EngineConfig.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package org.lunatech.dotty.using | ||
|
||
final case class EngineConfig(initialSpeed: Int, maxSpeed: Int, label: String) | ||
final case class EngineConfig(initialSpeed: Int, maxSpeed: Int, label: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
...ets/enumerations/src/main/scala/org/lunatech/dotty/enumeration/EnumMemberVisibility.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
package org.lunatech.dotty.enumeration | ||
|
||
@main def enumMemberVisibilityDefault = { | ||
|
||
enum Command { | ||
case Reset | ||
case IncrementBy(inc: Int) | ||
case Configure(init: Int, inc: Int) | ||
} | ||
|
||
val reset = Command.Reset // `reset` is a singleton case mapped to a val definition | ||
val inc = Command.IncrementBy(2) // `inc` is NOT a case class | ||
val reset = Command.Reset // `reset` is a singleton case mapped to a val definition | ||
val inc = Command.IncrementBy(2) // `inc` is NOT a case class | ||
|
||
val r1 = Command.Reset | ||
val r2 = Command.Reset | ||
|
||
println(r1 eq r2) // will print `true` | ||
println(r1 eq r2) // will print `true` | ||
println(s"reset.ordinal = ${reset.ordinal}") // will print reset.ordinal = 0 | ||
println(s"inc.ordinal = ${inc.ordinal}") | ||
|
||
} | ||
|
||
@main def enumMemberVisibility = { | ||
|
||
enum Command { | ||
case Reset | ||
case IncrementBy(inc: Int) | ||
case Configure(init: Int, inc: Int) | ||
} | ||
|
||
val inc = new Command.IncrementBy(2) // `inc` IS a case class | ||
val conf = new Command.Configure(0, 5) // `conf` IS a case class | ||
val inc = new Command.IncrementBy(2) // `inc` IS a case class | ||
val conf = new Command.Configure(0, 5) // `conf` IS a case class | ||
|
||
println(s"inc.ordinal = ${inc.ordinal}") | ||
println(s"conf = $conf") // will print Configure(0, 5) | ||
println(s"conf = $conf") // will print Configure(0, 5) | ||
val conf1 = conf.copy(inc = 7) | ||
println(s"conf1 = $conf1") // will print Configure(0, 7) | ||
conf1 // which members are defined on this enum instance? | ||
println(s"conf1 = $conf1") // will print Configure(0, 7) | ||
conf1 // which members are defined on this enum instance? | ||
} |
Oops, something went wrong.