Skip to content

Commit d530ae7

Browse files
authored
Partial fix for #19 (#75)
* - migrate cmd * - add contramap to Show, reformat implicitNotFound msg * - RESPParamWrite reformat implicitNotFound msg, reorg instances classes * - LowPriorityShowInstances -> ShowInstances and make sealed an package private * - ops revert to using traits for init order * - Read: modify implicitNotFound msg, replaced zip (unused and unneeded) with orElse (a bit more useful), combinators leverage Read constructors * - echo and ping now accept any A: Show, also require NonNullBulkString ==> A evidence * - reworded implicitNotFound msg, use widenLeft where appropriate * more fixes * - remove unneeded lazy vals in build.sbt for cross build components - add comment on why we shadow scala.js plugin * - toShowSyntax -> toShowOps * - address codacy issues * fixed compilation issue w/ scalatest 3.0.6 * wip geo * Ignoring metals+bloom directories * refactor Read instances names and grouping * Fixed benchmarks compilation issues * remove explicit evidence when not needed * mostly code formatting * more formatting * refactor all RESP ADTs * widen renamed to coerce where appropriate, more use of context bounds * shuffling things around * more cleanup, wip 2.11 broken * more tests * fixing 2.11 stack overflow in tests * formatting * more cleanup * BaseSpec in core + must => should * no implicit macro * adding transation watch/unwatch * cluster protocol commands * testing more refined types * completed tests on laserdisc-defined refined types * polishing up * removed manual refinements via refined API * removed unuseful RESPBuilder and made Arr a wrapper on List[RESP] instead of Vector[RESP] * no Show syntax, let Bulk handle Show * renamed Extra to Ext(ended) and added a few tests * roundtrip not round-trip * nodes, finally * bye bye 2.11 * minor README fix * more ClusterP testing * add cluster nodes test * cleaning up tests * fixed Host's RFC1123 hostname regex for JS * cluster cleanup * cluster cleanup - removed unnecessary parenthesis * more on geo protocol * completed geo protocol + tests * wip on hash and key protocols * removed last bit of 2.11/2.12 dichotomy * minor cosmetics around geo protocol spec * more hash tests * added glob pattern generator + test and completed hash protocol spec * wip key protocol * still wip key protocol testing * key protocol still missing SORT combinations * added list protocol tests * bump scalacheck to 1.14.0
1 parent 45902bc commit d530ae7

File tree

87 files changed

+6450
-3052
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+6450
-3052
lines changed

.gitignore

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
**/target/
1+
# Metals + Bloop
2+
.metals/
3+
.bloop/
4+
5+
# Intellij
26
.idea
7+
8+
# MacOS
39
*.DS_Store
10+
11+
# Anything else
12+
**/target/
413
local.*

.scalafmt.conf

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
align = true # For pretty alignment.
2-
maxColumn = 120 # For my wide 30" display.
2+
maxColumn = 140 # For my wide 30" display.

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ sudo: false
44
language: scala
55
scala:
66
- 2.12.8
7-
- 2.11.11-bin-typelevel-4
87

98
jdk:
109
- openjdk8

README.md

+7-9
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@ LaserDisc is a(nother) Scala driver for [Redis](https://redis.io/), written in S
2020
It differentiates itself from the others for having a core layer, which is made up of all the supported Redis commands
2121
and the Redis Serialization Protocol ([RESP](https://redis.io/topics/protocol)), that is strongly typed and which makes
2222
heavy use of [shapeless](https://github.com/milessabin/shapeless) and [refined](https://github.com/fthomas/refined) to
23-
achieve this. It's also worth noting that the core - in order to be built on scala 2.11.x - makes use of
24-
[Typelevel's Scala 2.11](https://typelevel.org/scala) fork, since it requires the enhancements on implicit heuristics. Finally, it also provides an implementation of RESP built using
25-
[scodec](http://scodec.org/).
23+
achieve this. It also provides an implementation of RESP built using [scodec](http://scodec.org/).
2624

2725
On top of this, one or more clients can be implemented. The only one currently available out of the box is built using
2826
[fs2](https://functional-streams-for-scala.github.io/fs2/)/[cats effect](https://typelevel.org/cats-effect/) but
@@ -48,7 +46,7 @@ Two reasons:
4846

4947
### Getting Started
5048

51-
LaserDisc is currently available for Scala 2.11 and 2.12 on the JVM.
49+
LaserDisc is currently available for Scala 2.12 on the JVM.
5250

5351
Its core (protocol commands and RESP wire format) is also available for [Scala.JS](http://www.scala-js.org/).
5452

@@ -69,7 +67,7 @@ Support for existing libraries is available via dedicated dependencies.
6967
#### [Circe](https://circe.github.io/circe/)
7068

7169
When an `io.circe.Decoder[A]` and a `io.circe.Encoder[A]` are implicilty available,
72-
instances of `Show[A]` and `Read[NonNullBulkString, A]` can be derived for free,
70+
instances of `Show[A]` and `Read[Bulk, A]` can be derived for free,
7371
just add the following in your `build.sbt`:
7472

7573
```
@@ -136,10 +134,10 @@ This should produce an output similar to the following one:
136134
[info] Running Main
137135
[info] - [ForkJoinPool-3-worker-2] Starting connection
138136
[info] - [ForkJoinPool-3-worker-2] Server available for publishing: localhost:6379
139-
[debug] - [ForkJoinPool-3-worker-5] sending Array(BulkString(SET),BulkString(a),BulkString(23))
140-
[debug] - [ForkJoinPool-3-worker-0] receiving SimpleString(OK)
141-
[debug] - [ForkJoinPool-3-worker-1] sending Array(BulkString(GET),BulkString(a))
142-
[debug] - [ForkJoinPool-3-worker-5] receiving BulkString(23)
137+
[debug] - [ForkJoinPool-3-worker-5] sending Arr(Bulk(SET),Bulk(a),Bulk(23))
138+
[debug] - [ForkJoinPool-3-worker-0] receiving Str(OK)
139+
[debug] - [ForkJoinPool-3-worker-1] sending Arr(Bulk(GET),Bulk(a))
140+
[debug] - [ForkJoinPool-3-worker-5] receiving Bulk(23)
143141
[info] - [ForkJoinPool-3-worker-2] yay!
144142
[info] - [ForkJoinPool-3-worker-2] Shutting down connection
145143
[info] - [ForkJoinPool-3-worker-0] Connection terminated: Right(())

benchmarks/core/src/main/scala/laserdisc/protocol/ProtocolBench.scala

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
package laserdisc.protocol
1+
package laserdisc
2+
package protocol
23

34
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
4-
import eu.timepit.refined.auto._
5-
import laserdisc.Maybe
6-
import laserdisc.protocol.RESP._
75
import shapeless._
86

97
@State(Scope.Benchmark)
108
class ProtocolBench {
11-
12-
private final val protocol = Protocol("CUSTOM", _: Int :: String :: Long :: Double :: HNil).as[SimpleString, OK]
9+
private final val protocol = Protocol("CUSTOM", _: Int :: String :: Long :: Double :: HNil).as[Str, OK]
1310

1411
private final val request = 0 :: "a" :: 1L :: 2.0d :: HNil
15-
private final val response = str("OK")
12+
private final val response = Str("OK")
1613

1714
@Benchmark def encode(): RESP = protocol(request).encode
1815
@Benchmark def decode(): Maybe[OK] = protocol(request).decode(response)
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package laserdisc.protocol
1+
package laserdisc
2+
package protocol
23

34
import java.nio.charset.StandardCharsets.UTF_8
45

5-
import laserdisc.protocol.RESP._
66
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
77
import scodec.bits.BitVector
88
import scodec.codecs.utf8
@@ -16,37 +16,37 @@ class RESPBench {
1616
private final val chars = 2000
1717

1818
private final val ok = "OK"
19-
private final val okRedis = s"+$ok\r\n"
19+
private final val okRedis = s"+$ok$CRLF"
2020
private final val rtProblem = "runtime problem"
21-
private final val rtProblemRedis = s"-$rtProblem\r\n"
21+
private final val rtProblemRedis = s"-$rtProblem$CRLF"
2222
private final val fortyTwo = 42L
23-
private final val fortyTwoRedis = s":$fortyTwo\r\n"
23+
private final val fortyTwoRedis = s":$fortyTwo$CRLF"
2424
private final val longString = new String(Array.fill(chars)('a'))
25-
private final val longStringRedis = s"$$$chars\r\n$longString\r\n"
25+
private final val longStringRedis = s"$$$chars$CRLF$longString$CRLF"
2626
private final val longStringI =
2727
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
2828

29-
private final val simpleString = str(ok)
30-
private final val simpleStringBits = BitVector(okRedis.getBytes(UTF_8))
31-
private final val error = err(rtProblem)
32-
private final val errorBits = BitVector(rtProblemRedis.getBytes(UTF_8))
33-
private final val integer = int(fortyTwo)
34-
private final val integerBits = BitVector(fortyTwoRedis.getBytes(UTF_8))
35-
private final val bulkString = bulk(longString)
36-
private final val bulkStringBits = BitVector(longStringRedis.getBytes(UTF_8))
37-
private final val longStringBits = BitVector(longString.getBytes(UTF_8))
38-
private final val longStringIBits = BitVector(longStringI.getBytes(UTF_8))
29+
private final val str = Str(ok)
30+
private final val strBits = BitVector(okRedis.getBytes(UTF_8))
31+
private final val err = Err(rtProblem)
32+
private final val errBits = BitVector(rtProblemRedis.getBytes(UTF_8))
33+
private final val num = Num(fortyTwo)
34+
private final val numBits = BitVector(fortyTwoRedis.getBytes(UTF_8))
35+
private final val bulk = Bulk(longString)
36+
private final val bulkBits = BitVector(longStringRedis.getBytes(UTF_8))
37+
private final val longStringBits = BitVector(longString.getBytes(UTF_8))
38+
private final val longStringIBits = BitVector(longStringI.getBytes(UTF_8))
3939

4040
@Benchmark def baseline_utf8_encode: Attempt[BitVector] = utf8.encode(longString)
4141
@Benchmark def baseline_utf8_decode: Attempt[String] = utf8.decodeValue(longStringBits)
4242
@Benchmark def baseline_utf8_encodeI: Attempt[BitVector] = utf8.encode(longStringI)
4343
@Benchmark def baseline_utf8_decodeI: Attempt[String] = utf8.decodeValue(longStringIBits)
44-
@Benchmark def simpleString_encode: Attempt[BitVector] = codec.encode(simpleString)
45-
@Benchmark def simpleString_decode: Attempt[RESP] = codec.decodeValue(simpleStringBits)
46-
@Benchmark def error_encode: Attempt[BitVector] = codec.encode(error)
47-
@Benchmark def error_decode: Attempt[RESP] = codec.decodeValue(errorBits)
48-
@Benchmark def integer_encode: Attempt[BitVector] = codec.encode(integer)
49-
@Benchmark def integer_decode: Attempt[RESP] = codec.decodeValue(integerBits)
50-
@Benchmark def bulkString_encode: Attempt[BitVector] = codec.encode(bulkString)
51-
@Benchmark def bulkString_decode: Attempt[RESP] = codec.decodeValue(bulkStringBits)
44+
@Benchmark def str_encode: Attempt[BitVector] = codec.encode(str)
45+
@Benchmark def str_decode: Attempt[RESP] = codec.decodeValue(strBits)
46+
@Benchmark def err_encode: Attempt[BitVector] = codec.encode(err)
47+
@Benchmark def err_decode: Attempt[RESP] = codec.decodeValue(errBits)
48+
@Benchmark def num_encode: Attempt[BitVector] = codec.encode(num)
49+
@Benchmark def num_decode: Attempt[RESP] = codec.decodeValue(numBits)
50+
@Benchmark def bulk_encode: Attempt[BitVector] = codec.encode(bulk)
51+
@Benchmark def bulk_decode: Attempt[RESP] = codec.decodeValue(bulkBits)
5252
}

benchmarks/core/src/main/scala/laserdisc/protocol/RESPParamWriteBench.scala

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package laserdisc.protocol
1+
package laserdisc
2+
package protocol
23

34
import org.openjdk.jmh.annotations.{Benchmark, Scope, State}
45
import shapeless._
@@ -10,5 +11,5 @@ class RESPParamWriteBench {
1011

1112
private final val value = 0 :: "a" :: 1L :: 2.0d :: HNil
1213

13-
@Benchmark def write(): Seq[BulkString] = respParamWrite.write(value)
14+
@Benchmark def write(): Seq[GenBulk] = respParamWrite.write(value)
1415
}

benchmarks/core/src/main/scala/laserdisc/protocol/UTF8EncodingBench.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
package laserdisc.protocol
1+
package laserdisc
2+
package protocol
23

34
import java.nio.ByteBuffer
45
import java.nio.charset.StandardCharsets.UTF_8

build.sbt

+35-57
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,39 @@
1-
import sbtcrossproject.CrossPlugin.autoImport.crossProject
2-
import sbtcrossproject.CrossType
1+
// shadow sbt-scalajs' crossProject and CrossType from Scala.js 0.6.x
2+
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
33

4-
val `scala 211` = "2.11.11-bin-typelevel-4"
5-
val `scala 212` = "2.12.8"
4+
val `scala 2.12` = "2.12.8"
65

76
val V = new {
87
val circe = "0.11.1"
98
val fs2 = "1.0.5"
109
val `kind-projector` = "0.9.10"
1110
val kittens = "1.2.1"
11+
val `log-effect-fs2` = "0.8.0"
1212
val refined = "0.9.9"
13-
val refined211 = "0.8.7"
14-
val scalacheck = "1.13.5"
13+
val scalacheck = "1.14.0"
1514
val scalatest = "3.0.8"
1615
val `scodec-bits` = "1.1.12"
1716
val `scodec-core` = "1.11.4"
1817
val `scodec-stream` = "1.2.1"
1918
val shapeless = "2.3.3"
20-
val `log-effect-fs2` = "0.8.0"
2119
}
2220

23-
val `circe-core` = Def.setting("io.circe" %%% "circe-core" % V.circe)
24-
val `circe-parser` = Def.setting("io.circe" %%% "circe-parser" % V.circe)
25-
val `fs2-core` = Def.setting("co.fs2" %%% "fs2-core" % V.fs2)
26-
val `fs2-io` = Def.setting("co.fs2" %% "fs2-io" % V.fs2)
27-
val kittens = Def.setting("org.typelevel" %%% "kittens" % V.kittens)
28-
val `scodec-bits` = Def.setting("org.scodec" %%% "scodec-bits" % V.`scodec-bits`)
29-
val `scodec-core` = Def.setting("org.scodec" %%% "scodec-core" % V.`scodec-core`)
30-
val `scodec-stream` = Def.setting("org.scodec" %%% "scodec-stream" % V.`scodec-stream`)
31-
val shapeless = Def.setting("com.chuusai" %%% "shapeless" % V.shapeless)
32-
val `log-effect-fs2` = Def.setting("io.laserdisc" %%% "log-effect-fs2" % V.`log-effect-fs2`)
33-
val `circe-generic` = Def.setting("io.circe" %%% "circe-generic" % V.circe % Test)
34-
val scalacheck = Def.setting("org.scalacheck" %%% "scalacheck" % V.scalacheck % Test)
35-
val scalatest = Def.setting("org.scalatest" %%% "scalatest" % V.scalatest % Test)
36-
val refined = Def.setting {
37-
is211.value match {
38-
case true => "eu.timepit" %%% "refined" % V.refined211
39-
case _ => "eu.timepit" %%% "refined" % V.refined
40-
}
41-
}
21+
val `circe-core` = Def.setting("io.circe" %%% "circe-core" % V.circe)
22+
val `circe-parser` = Def.setting("io.circe" %%% "circe-parser" % V.circe)
23+
val `fs2-core` = Def.setting("co.fs2" %%% "fs2-core" % V.fs2)
24+
val `fs2-io` = Def.setting("co.fs2" %% "fs2-io" % V.fs2)
25+
val kittens = Def.setting("org.typelevel" %%% "kittens" % V.kittens)
26+
val `log-effect-fs2` = Def.setting("io.laserdisc" %%% "log-effect-fs2" % V.`log-effect-fs2`)
27+
val refined = Def.setting("eu.timepit" %%% "refined" % V.refined)
28+
val `scodec-bits` = Def.setting("org.scodec" %%% "scodec-bits" % V.`scodec-bits`)
29+
val `scodec-core` = Def.setting("org.scodec" %%% "scodec-core" % V.`scodec-core`)
30+
val `scodec-stream` = Def.setting("org.scodec" %%% "scodec-stream" % V.`scodec-stream`)
31+
val shapeless = Def.setting("com.chuusai" %%% "shapeless" % V.shapeless)
32+
33+
val `circe-generic` = Def.setting("io.circe" %%% "circe-generic" % V.circe % Test)
34+
val `refined-scalacheck` = Def.setting("eu.timepit" %%% "refined-scalacheck" % V.refined % Test)
35+
val scalacheck = Def.setting("org.scalacheck" %%% "scalacheck" % V.scalacheck % Test)
36+
val scalatest = Def.setting("org.scalatest" %%% "scalatest" % V.scalatest % Test)
4237

4338
val `kind-projector-compiler-plugin` = Def.setting {
4439
compilerPlugin("org.spire-math" % "kind-projector" % V.`kind-projector` cross CrossVersion.binary)
@@ -54,6 +49,7 @@ val coreDeps = Def.Initialize.join {
5449
`scodec-core`,
5550
shapeless,
5651
refined,
52+
`refined-scalacheck`,
5753
scalacheck,
5854
scalatest
5955
)
@@ -65,8 +61,8 @@ val fs2Deps = Def.Initialize.join {
6561
`fs2-io`,
6662
`kind-projector-compiler-plugin`,
6763
kittens,
68-
`scodec-stream`,
6964
`log-effect-fs2`,
65+
`scodec-stream`,
7066
scalacheck,
7167
scalatest
7268
)
@@ -113,7 +109,7 @@ val externalApiMappings = Def.task {
113109
}
114110

115111
val versionDependantScalacOptions = Def.setting {
116-
def versionDependent(scalaVersion: String, flags: Seq[String]) =
112+
def versionDependent(scalaVersion: String, flags: Seq[String]) =
117113
CrossVersion.partialVersion(scalaVersion) match {
118114
case Some((2, major)) if major >= 12 =>
119115
flags ++ Seq(
@@ -126,11 +122,9 @@ val versionDependantScalacOptions = Def.setting {
126122
"-Ywarn-unused:privates", // Warn if a private member is unused.
127123
"-Ywarn-value-discard" // Warn when non-Unit expression results are unused.
128124
)
129-
case _ =>
130-
(flags ++ Seq("-Yinduction-heuristics", "-Yliteral-types"))
131-
.filterNot(_ == "-Xlint:missing-interpolator") //@implicitNotFound uses ${A} syntax w/o need for s interpolator
125+
case _ => flags
132126
}
133-
127+
134128
val flags = Seq(
135129
"-deprecation", // Emit warning and location for usages of deprecated APIs.
136130
"-encoding",
@@ -168,7 +162,7 @@ val versionDependantScalacOptions = Def.setting {
168162
"-Ywarn-infer-any", // Warn when a type argument is inferred to be `Any`.
169163
"-Ywarn-nullary-override", // Warn when non-nullary `def f()' overrides nullary `def f'.
170164
"-Ywarn-nullary-unit", // Warn when nullary methods return Unit.
171-
"-Ywarn-numeric-widen", // Warn when numerics are widened.
165+
"-Ywarn-numeric-widen" // Warn when numerics are widened.
172166
)
173167

174168
versionDependent(scalaVersion.value, flags)
@@ -177,17 +171,13 @@ val versionDependantScalacOptions = Def.setting {
177171
inThisBuild {
178172
Def.settings(
179173
organization := "io.laserdisc",
180-
scalaVersion := `scala 212`
174+
scalaVersion := `scala 2.12`
181175
)
182176
}
183177

184178
lazy val commonSettings = Seq(
185-
scalaOrganization :=
186-
(CrossVersion.partialVersion(scalaVersion.value) match {
187-
case Some((2, 11)) => "org.typelevel"
188-
case _ => "org.scala-lang"
189-
}),
190-
crossScalaVersions := Seq(`scala 211`, `scala 212`),
179+
scalaOrganization := "org.scala-lang",
180+
crossScalaVersions := Seq(`scala 2.12`),
191181
scalacOptions ++= versionDependantScalacOptions.value,
192182
Compile / console / scalacOptions --= Seq("-Ywarn-unused:imports", "-Xfatal-warnings"),
193183
Test / console / scalacOptions := (Compile / console / scalacOptions).value
@@ -237,18 +227,8 @@ lazy val scoverageSettings = Seq(
237227
coverageMinimum := 60,
238228
coverageFailOnMinimum := false,
239229
coverageHighlighting := true,
240-
coverageEnabled := {
241-
if (is211.value) false else coverageEnabled.value
242-
}
243230
)
244231

245-
lazy val is211 = Def.setting {
246-
CrossVersion.partialVersion(scalaVersion.value) match {
247-
case Some((2, 11)) => true
248-
case _ => false
249-
}
250-
}
251-
252232
lazy val allSettings = commonSettings ++ testSettings ++ scaladocSettings ++ publishSettings ++ scoverageSettings
253233

254234
lazy val scalaJsTLSSettings = Seq(
@@ -265,7 +245,8 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
265245
.settings(
266246
name := "laserdisc-core",
267247
libraryDependencies ++= coreDeps.value,
268-
Compile / boilerplateSource := baseDirectory.value.getParentFile / "src" / "main" / "boilerplate"
248+
Compile / boilerplateSource := baseDirectory.value.getParentFile / "src" / "main" / "boilerplate",
249+
Test / boilerplateSource := baseDirectory.value.getParentFile / "src" / "test" / "boilerplate"
269250
)
270251
.jvmSettings(
271252
javaOptions += "-Djava.net.preferIPv4Stack=true",
@@ -311,7 +292,7 @@ lazy val cli = project
311292

312293
lazy val circe = crossProject(JSPlatform, JVMPlatform)
313294
.withoutSuffixFor(JVMPlatform)
314-
.crossType(CrossType.Pure)
295+
.crossType(CrossType.Pure)
315296
.in(file("circe"))
316297
.dependsOn(core)
317298
.settings(allSettings)
@@ -321,13 +302,10 @@ lazy val circe = crossProject(JSPlatform, JVMPlatform)
321302
)
322303
.jsSettings(scalaJsTLSSettings: _*)
323304

324-
lazy val circeJVM = circe.jvm
325-
lazy val circeJS = circe.js
326-
327305
lazy val laserdisc = project
328306
.in(file("."))
329-
.aggregate(coreJVM, coreJS, fs2, cli, circeJVM, circeJS)
307+
.aggregate(coreJVM, coreJS, fs2, cli, circe.jvm, circe.js)
330308
.settings(publishSettings)
331309
.settings(
332310
publishArtifact := false
333-
)
311+
)

circe/src/main/scala/laserdisc/interop/circe.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@ package interop
33

44
import io.circe._
55
import io.circe.syntax._
6-
import laserdisc.protocol.NonNullBulkString
76

87
object circe {
98
implicit final def encoderShow[A: Encoder]: Show[A] = Show.instance(_.asJson.noSpaces)
10-
implicit final def decoderRead[A: Decoder]: Read[NonNullBulkString, A] = Read.instance {
11-
case NonNullBulkString(s) =>
9+
implicit final def decoderRead[A: Decoder]: Bulk ==> A = Read.instance {
10+
case Bulk(s) =>
1211
parser.decode(s) match {
1312
case Right(a) => Some(a)
1413
case _ => None

0 commit comments

Comments
 (0)