Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sbt-typelevel to 0.5.3 #524

Merged
merged 12 commits into from
Sep 27, 2023
189 changes: 106 additions & 83 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ ThisBuild / scalaVersion := scala213

ThisBuild / githubWorkflowBuildPostamble +=
WorkflowStep.Sbt(
List("set ThisBuild / tlFatalWarningsInCi := false", "documentation/mdoc"),
List("set ThisBuild / tlFatalWarnings := false", "documentation/mdoc"),
None,
Some("Compile documentation"),
Some(s"matrix.scala == '$scala213' && matrix.project == 'rootJVM'")
Some(s"matrix.scala == '2.13' && matrix.project == 'rootJVM'")
)

val commonSettings = List(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ package cbor

import low._

import fs2._

import weaver._

import cats.effect._
Expand Down
9 changes: 9 additions & 0 deletions csv/shared/src/main/scala/fs2/data/csv/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import cats.data._
import cats.syntax.all._

import scala.annotation.{implicitNotFound, unused}
import scala.annotation.nowarn

package object csv {

Expand Down Expand Up @@ -81,6 +82,7 @@ package object csv {
"No implicit CsvRowEncoderF[H, found for type ${T}.\nYou can define one using CsvRowEncoderF[H, .instance, by calling contramap on another CsvRowEncoderF[H, or by using generic derivation for product types like case classes.\nFor that, add the fs2-data-csv-generic module to your dependencies and use either full-automatic derivation:\nimport fs2.data.csv.generic.auto._\nor the recommended semi-automatic derivation:\nimport fs2.data.csv.generic.semiauto._\nimplicit val csvRowEncoder: CsvRowEncoderF[H, [${T}] = deriveCsvRowEncoderF[H, \nMake sure to have instances of CellEncoder for every member type in scope.\n")
type CsvRowEncoder[T, Header] = RowEncoderF[Some, T, Header]

@nowarn
sealed trait QuoteHandling

object QuoteHandling {
Expand Down Expand Up @@ -108,6 +110,7 @@ package object csv {
def decodeWithoutHeaders[T]: PartiallyAppliedDecodeWithoutHeaders[T] =
new PartiallyAppliedDecodeWithoutHeaders[T](dummy = true)

@nowarn
class PartiallyAppliedDecodeWithoutHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_], C](separator: Char = ',', quoteHandling: QuoteHandling = QuoteHandling.RFCCompliant)(implicit
F: RaiseThrowable[F],
Expand All @@ -122,6 +125,7 @@ package object csv {
def decodeSkippingHeaders[T]: PartiallyAppliedDecodeSkippingHeaders[T] =
new PartiallyAppliedDecodeSkippingHeaders[T](dummy = true)

@nowarn
class PartiallyAppliedDecodeSkippingHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_], C](separator: Char = ',', quoteHandling: QuoteHandling = QuoteHandling.RFCCompliant)(implicit
F: RaiseThrowable[F],
Expand All @@ -137,6 +141,7 @@ package object csv {
def decodeUsingHeaders[T]: PartiallyAppliedDecodeUsingHeaders[T] =
new PartiallyAppliedDecodeUsingHeaders[T](dummy = true)

@nowarn
class PartiallyAppliedDecodeUsingHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_], C, Header](separator: Char = ',', quoteHandling: QuoteHandling = QuoteHandling.RFCCompliant)(
implicit
Expand All @@ -158,6 +163,7 @@ package object csv {
def decodeGivenHeaders[T]: PartiallyAppliedDecodeGivenHeaders[T] =
new PartiallyAppliedDecodeGivenHeaders(dummy = true)

@nowarn
class PartiallyAppliedDecodeGivenHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_], C, Header](headers: NonEmptyList[Header],
skipHeaders: Boolean = false,
Expand All @@ -178,6 +184,7 @@ package object csv {
def encodeWithoutHeaders[T]: PartiallyAppliedEncodeWithoutHeaders[T] =
new PartiallyAppliedEncodeWithoutHeaders[T](dummy = true)

@nowarn
class PartiallyAppliedEncodeWithoutHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_]](fullRows: Boolean = false,
separator: Char = ',',
Expand All @@ -194,6 +201,7 @@ package object csv {
def encodeGivenHeaders[T]: PartiallyAppliedEncodeGivenHeaders[T] =
new PartiallyAppliedEncodeGivenHeaders[T](dummy = true)

@nowarn
class PartiallyAppliedEncodeGivenHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_], Header](headers: NonEmptyList[Header],
fullRows: Boolean = false,
Expand All @@ -213,6 +221,7 @@ package object csv {
def encodeUsingFirstHeaders[T]: PartiallyAppliedEncodeUsingFirstHeaders[T] =
new PartiallyAppliedEncodeUsingFirstHeaders(dummy = true)

@nowarn
class PartiallyAppliedEncodeUsingFirstHeaders[T](val dummy: Boolean) extends AnyVal {
def apply[F[_], Header](fullRows: Boolean = false,
separator: Char = ',',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object CsvExceptionSpec extends SimpleIOSuite {
List(Right(Row(NonEmptyList("1", List("2", "3")))),
Right(Row(NonEmptyList("a", List("b", "c")))),
Left(e: CsvException))) =>
e.line.contains(3) // check that we have the correct line number here
e.line.contains(3L) // check that we have the correct line number here
case _ => false
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package fs2.data.esp

/** A typeclass to create events out of tags. */
trait Conversion[Tag, Evt] {
def makeOpen(t: Tag): Evt
def makeClose(t: Tag): Evt
def makeLeaf(t: Tag): Evt
trait Conversion[T, Evt] {
def makeOpen(t: T): Evt
def makeClose(t: T): Evt
def makeLeaf(t: T): Evt
}
44 changes: 22 additions & 22 deletions finite-state/shared/src/main/scala/fs2/data/esp/Pattern.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,43 +25,43 @@ import cats.syntax.all._
/** A pattern to be matched.
* A pattern can capture a submatch, that is then usable in the RHS.
*/
sealed trait Pattern[Guard, Tag] {
def |(that: Pattern[Guard, Tag]): Pattern[Guard, Tag] =
sealed trait Pattern[Guard, T] {
def |(that: Pattern[Guard, T]): Pattern[Guard, T] =
(this, that) match {
case (Pattern.Wildcard(), _) | (_, Pattern.Wildcard()) => Pattern.Wildcard()
case (Pattern.Or(alts1), Pattern.Or(alts2)) => Pattern.Or(alts1 ++ alts2)
case (_, _) => Pattern.Or(NonEmptyChain(this, that))
}

def when(guard: Guard): Pattern[Guard, Tag] =
def when(guard: Guard): Pattern[Guard, T] =
Pattern.Guarded(this, guard)
}

object Pattern {

/** Matches anything. */
case class Wildcard[Guard, Tag]() extends Pattern[Guard, Tag]
case class Wildcard[Guard, T]() extends Pattern[Guard, T]

/** Matches the end of stream. */
case class EOS[Guard, Tag]() extends Pattern[Guard, Tag]
case class EOS[Guard, T]() extends Pattern[Guard, T]

/** Matches the input in a state at a depth for some input pattern. */
case class Input[Guard, Tag](q: Option[Int], d: Option[Int], inner: Pattern[Guard, Tag]) extends Pattern[Guard, Tag]
case class Input[Guard, T](q: Option[Int], d: Option[Int], inner: Pattern[Guard, T]) extends Pattern[Guard, T]

/** Matches some open tag. */
case class Open[Guard, Tag](tag: Option[Tag]) extends Pattern[Guard, Tag]
case class Open[Guard, T](tag: Option[T]) extends Pattern[Guard, T]

/** Matches some close tag. */
case class Close[Guard, Tag](tag: Option[Tag]) extends Pattern[Guard, Tag]
case class Close[Guard, T](tag: Option[T]) extends Pattern[Guard, T]

/** Matches some leaf value. */
case class Leaf[Guard, Tag](value: Option[Tag]) extends Pattern[Guard, Tag]
case class Leaf[Guard, T](value: Option[T]) extends Pattern[Guard, T]

/** Alternative, matched from left to right. */
case class Or[Guard, Tag](patterns: NonEmptyChain[Pattern[Guard, Tag]]) extends Pattern[Guard, Tag]
case class Or[Guard, T](patterns: NonEmptyChain[Pattern[Guard, T]]) extends Pattern[Guard, T]

/** A guarded pattern. */
case class Guarded[Guard, Tag](inner: Pattern[Guard, Tag], guard: Guard) extends Pattern[Guard, Tag]
case class Guarded[Guard, T](inner: Pattern[Guard, T], guard: Guard) extends Pattern[Guard, T]

implicit def PatternIsPattern[G, T]: IsPattern[Pattern[G, T], G, Tag[T]] =
new IsPattern[Pattern[G, T], G, Tag[T]] {
Expand Down Expand Up @@ -131,36 +131,36 @@ object Pattern {

}

class PatternDsl[Guard, Tag] {
class PatternDsl[Guard, T] {

def state(q: Int)(inner: Pattern[Guard, Tag]): Pattern[Guard, Tag] =
def state(q: Int)(inner: Pattern[Guard, T]): Pattern[Guard, T] =
Pattern.Input(q.some, none, inner)

def state(q: Int, d: Int)(inner: Pattern[Guard, Tag]): Pattern[Guard, Tag] =
def state(q: Int, d: Int)(inner: Pattern[Guard, T]): Pattern[Guard, T] =
Pattern.Input(q.some, d.some, inner)

def value(v: Tag): Pattern[Guard, Tag] =
def value(v: T): Pattern[Guard, T] =
Pattern.Leaf(v.some)

val value: Pattern[Guard, Tag] =
val value: Pattern[Guard, T] =
Pattern.Leaf(none)

val eos: Pattern[Guard, Tag] =
val eos: Pattern[Guard, T] =
Pattern.EOS()

val any: Pattern[Guard, Tag] =
val any: Pattern[Guard, T] =
Pattern.Wildcard()

def open(t: Tag): Pattern[Guard, Tag] =
def open(t: T): Pattern[Guard, T] =
Pattern.Open(t.some)

val open: Pattern[Guard, Tag] =
val open: Pattern[Guard, T] =
Pattern.Open(none)

def close(t: Tag): Pattern[Guard, Tag] =
def close(t: T): Pattern[Guard, T] =
Pattern.Close(t.some)

val close: Pattern[Guard, Tag] =
val close: Pattern[Guard, T] =
Pattern.Close(none)

}
4 changes: 2 additions & 2 deletions finite-state/shared/src/main/scala/fs2/data/esp/Rhs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ sealed trait Rhs[+OutTag]
object Rhs {

/** Calls a new rule at a given depth with the given parameters. */
case class Call[Tag](q: Int, depth: Depth, params: List[Rhs[Tag]]) extends Rhs[Tag]
case class Call[T](q: Int, depth: Depth, params: List[Rhs[T]]) extends Rhs[T]

/** Calls a new rule at a given depth with the given parameters on the current input. */
case class SelfCall[Tag](q: Int, params: List[Rhs[Tag]]) extends Rhs[Tag]
case class SelfCall[T](q: Int, params: List[Rhs[T]]) extends Rhs[T]

/** Reads the rule parameter. */
case class Param(n: Int) extends Rhs[Nothing]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,43 +94,44 @@ private[fs2] abstract class QueryCompiler[Tag, Path] {
})
}.toMap
// we can apply the DFA to MFT translation now
transitionCases.foldLeft(Map(dfa.init -> start)) { case (states, (src, transitions)) =>
val initialSrc = src === dfa.init
val (q1, states1) =
states.get(src) match {
case Some(q1) => (q1, states)
case None =>
val q1 =
if (initialSrc)
start
else
state(args = start.nargs)
(q1, states.updated(src, q1))
}
val copyArgs = List.tabulate(q1.nargs)(y(_))
val states2 =
transitions.foldLeft(states1) { case (states, (pattern, guard, tgt)) =>
val finalTgt = dfa.finals.contains(tgt)
val (q2, states1) =
states.get(tgt) match {
case Some(q2) => (q2, states)
case None =>
val q2 = state(args = q1.nargs)
(q2, states.updated(tgt, q2))
val _ =
transitionCases.foldLeft(Map(dfa.init -> start)) { case (states, (src, transitions)) =>
val initialSrc = src === dfa.init
val (q1, states1) =
states.get(src) match {
case Some(q1) => (q1, states)
case None =>
val q1 =
if (initialSrc)
start
else
state(args = start.nargs)
(q1, states.updated(src, q1))
}
val copyArgs = List.tabulate(q1.nargs)(y(_))
val states2 =
transitions.foldLeft(states1) { case (states, (pattern, guard, tgt)) =>
val finalTgt = dfa.finals.contains(tgt)
val (q2, states1) =
states.get(tgt) match {
case Some(q2) => (q2, states)
case None =>
val q2 = state(args = q1.nargs)
(q2, states.updated(tgt, q2))
}
val pat: builder.Guardable = tagOf(pattern).fold(anyNode)(aNode(_))
if (!finalTgt) {
q1(pat.when(guard)) -> q2(x1, copyArgs: _*) ~ q1(x2, copyArgs: _*)
} else {
q1(pat.when(guard)) -> end(x1, (copyArgs :+ copy(qcopy(x1))): _*) ~ q2(x1, copyArgs: _*) ~
q1(x2, copyArgs: _*)
}
val pat: builder.Guardable = tagOf(pattern).fold(anyNode)(aNode(_))
if (!finalTgt) {
q1(pat.when(guard)) -> q2(x1, copyArgs: _*) ~ q1(x2, copyArgs: _*)
} else {
q1(pat.when(guard)) -> end(x1, (copyArgs :+ copy(qcopy(x1))): _*) ~ q2(x1, copyArgs: _*) ~
q1(x2, copyArgs: _*)
states1
}
states1
}
q1(anyLeaf) -> eps
q1(epsilon) -> eps
states2
}: Unit
q1(anyLeaf) -> eps
q1(epsilon) -> eps
states2
}
}

def translate(query: Query[Tag, Path], vars: List[String], q: builder.StateBuilder): Unit =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package fs2.data.pfsa

trait Candidate[Set, C] {
trait Candidate[S, C] {

def pick(set: Set): Option[C]
def pick(set: S): Option[C]

}
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ object Regular {
private case class And[CharSet](re1: Regular[CharSet], re2: Regular[CharSet]) extends Regular[CharSet]
private case class Not[CharSet](re: Regular[CharSet]) extends Regular[CharSet]

implicit def eq[CharSet: Eq]: Eq[Regular[CharSet]] = Eq.instance {
private[pfsa] def eq[CharSet: Eq]: Eq[Regular[CharSet]] = regeq[CharSet]

implicit def regeq[CharSet: Eq]: Eq[Regular[CharSet]] = Eq.instance {
case (Epsilon(), Epsilon()) => true
case (Chars(cs1), Chars(cs2)) => cs1 === cs2
case (Star(re1), Star(re2)) => re1 === re2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ private[json] class JsonTokenParser[F[_], T, Res](
private[this] final val chunkAcc: ChunkAccumulator[Res])(implicit F: RaiseThrowable[F], T: AsCharBuffer[F, T]) {
private[this] var context = T.create(s)

private[this] def emitChunk[T]() =
private[this] def emitChunk() =
Pull.output(chunkAcc.chunk())

// the opening quote has already been read
Expand Down
9 changes: 6 additions & 3 deletions json/src/main/scala/fs2/data/json/jsonpath/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ package fs2
package data
package json

import cats.effect.Concurrent
import cats.syntax.all._

import scala.annotation.nowarn

import ast.Builder
import jsonpath.internals._
import pfsa.{PDFA, PNFA}

import cats.effect.Concurrent
import cats.syntax.all._

package object jsonpath {

/** Namespace containing the various JsonPath filtering pipes. */
def filter[F[_]]: PartiallyAppliedFilter[F] = new PartiallyAppliedFilter(true)

/** Namespace containing the various JsonPath filtering pipes. */
@nowarn
final class PartiallyAppliedFilter[F[_]] private[jsonpath] (val dummy: Boolean) extends AnyVal {

/** Selects all macthing elements in the input stream. Each matching element is emitted in a new stream.
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)

addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.4.22")
addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.5.3")

addSbtPlugin("com.github.sbt" % "sbt-unidoc" % "0.5.0")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ package object scalaXml {

private def makeAttributes(md: MetaData, acc: List[Attr]): List[Attr] =
md match {
case Null => acc.reverse
case PrefixedAttribute(prefix, key, value, next) =>
makeAttributes(next, Attr(QName(Option(prefix), key), makeTexty(value.toList)) :: acc)
case UnprefixedAttribute(key, value, next) =>
makeAttributes(next, Attr(QName(key), makeTexty(value.toList)) :: acc)
case _ => acc.reverse
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ private[xml] object EventParser {
case (ctx, chunkAcc, '-') =>
acceptChar(ctx, '>', "15", "'--' is not inside comments", chunkAcc)
case (ctx, chunkAcc, c) =>
if (includeComments) builder.append('-').append(c)
if (includeComments) { val _ = builder.append('-').append(c) }
loop(ctx, builder, chunkAcc)
}
case (ctx, chunkAcc, c) =>
Expand Down
Loading