8000 Support scala 3 by cquiroz · Pull Request #290 · typelevel/cats-time · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support scala 3 #290

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

Merged
merged 2 commits into from
Aug 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [adopt@1.8, adopt@1.11, adopt@1.14]
scala: [2.12.12, 2.13.3]
java: [adopt@1.8, adopt@1.11, adopt@1.16]
scala: [2.12.13, 2.13.6, 3.0.1]
env:
SCALA_VERSION: ${{ matrix.scala }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v10
- uses: olafurpg/setup-scala@v12
with:
java-version: ${{ matrix.java }}
- name: Cache dependencies
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
- uses: olafurpg/setup-scala@v12
- name: Cache dependencies
uses: actions/cache@v2
with:
Expand Down
25 changes: 11 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}

Global / onChangedBuildSource := ReloadOnSourceChanges

lazy val `cats-time` = project
.in(file("."))
.disablePlugins(MimaPlugin)
.enablePlugins(NoPublishPlugin)
.settings(commonSettings)
.aggregate(coreJS, coreJVM)
.aggregate(core.jvm, core.jvm)

lazy val core = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
Expand All @@ -18,13 +20,10 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
libraryDependencies += "io.github.cquiroz" %%% "s 8000 cala-java-time" % "2.3.0"
)

lazy val coreJS = core.js
lazy val coreJVM = core.jvm

lazy val docs = project
.in(file("modules/docs"))
.settings(commonSettings, micrositeSettings)
.dependsOn(coreJVM)
.dependsOn(core.jvm)
.disablePlugins(MimaPlugin)
.enablePlugins(MicrositesPlugin)
.enablePlugins(MdocPlugin)
Expand All @@ -33,14 +32,12 @@ lazy val docs = project

// General Settings
lazy val commonSettings = Seq(
scalaVersion := "2.13.6",
crossScalaVersions := Seq(scalaVersion.value, "2.12.14"),
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.13.1" cross CrossVersion.full),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
scalaVersion := "3.0.1",
crossScalaVersions := Seq("3.0.1", "2.12.13", "2.13.6"),
libraryDependencies ++= Seq(
"org.typelevel" %%% "cats-core" % "2.6.1",
"org.typelevel" %%% "cats-core" % "2.6.1",
"org.typelevel" %%% "cats-testkit-scalatest" % "2.1.5" % Test,
"org.scala-lang.modules" %%% "scala-collection-compat" % "2.5.0" % Test,
"org.typelevel" %%% "cats-testkit-scalatest" % "2.1.5" % Test
)
)

Expand All @@ -64,7 +61,7 @@ lazy val micrositeSettings = Seq(
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"
),
scalacOptions in Compile --= Seq(
Compile / scalacOptions --= Seq(
"-Xfatal-warnings",
"-Ywarn-unused-import",
"-Ywarn-numeric-widen",
Expand Down Expand Up @@ -94,10 +91,10 @@ inThisBuild(
homepage := Some(url("https://github.com/typelevel/cats-time")),
licenses += ("MIT", url("http://opensource.org/licenses/MIT")),
pomIncludeRepository := { _ => false },
scalacOptions in (Compile, doc) ++= Seq(
Compile / doc / scalacOptions ++= Seq(
"-groups",
"-sourcepath",
(baseDirectory in LocalRootProject).value.getAbsolutePath,
(LocalRootProject / baseDirectory).value.getAbsolutePath,
"-doc-source-url",
"https://github.com/typelevel/cats-time/blob/v" + version.value + "€{FILE_PATH}.scala"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import cats._
import java.time.Instant

trait instant {
implicit final val instantInstances =
implicit final val instantInstances: Hash[Instant] with Order[Instant] with Show[Instant] =
new Hash[Instant] with Order[Instant] with Show[Instant] {
override def hash(x: Instant): Int = x.hashCode
override def compare(x: Instant, y: Instant): Int = x.compareTo(y)
override def show(x: Instant): String = x.toString
}

}

object instant extends instant
object instant extends instant

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ trait localdate {
final def showLocalDate(formatter: DateTimeFormatter): Show[LocalDate] =
Show[String].contramap(_.format(formatter))

implicit final val localdateInstances =
new Show[LocalDate] with Order[LocalDate] with Hash[LocalDate]{
implicit final val localdateInstances: Show[LocalDate]
with Order[LocalDate]
with Hash[LocalDate] =
new Show[LocalDate] with Order[LocalDate] with Hash[LocalDate] {
override def hash(x: LocalDate): Int = x.hashCode
override def compare(x: LocalDate, y: LocalDate): Int = x.compareTo(y)
override def show(x: LocalDate): String = x.format(ISO_LOCAL_DATE)
}
}

object localdate extends localdate
object localdate extends localdate

Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ trait localdatetime {
final def showLocalDateTime(formatter: DateTimeFormatter): Show[LocalDateTime] =
Show[String].contramap(_.format(formatter))

implicit final val localdatetimeInstances =
implicit final val localdatetimeInstances: Show[LocalDateTime] with Order[LocalDateTime] with Hash[LocalDateTime] =
new Show[LocalDateTime] with Order[LocalDateTime] with Hash[LocalDateTime]{
override def hash(x: LocalDateTime): Int = x.hashCode
override def compare(x: LocalDateTime, y: LocalDateTime): Int = x.compareTo(y)
override def show(x: LocalDateTime): String = x.format(ISO_LOCAL_DATE_TIME)
}
}

object localdatetime extends localdatetime
object localdatetime extends localdatetime
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ trait localtime {
final def showLocalTime(formatter: DateTimeFormatter): Show[LocalTime] =
Show[String].contramap(_.format(formatter))

implicit final val localtimeInstances =
new Show[LocalTime] with Order[LocalTime] with Hash[LocalTime]{
implicit final val localtimeInstances: Show[LocalTime]
with Order[LocalTime]
with Hash[LocalTime] =
new Show[LocalTime] with Order[LocalTime] with Hash[LocalTime] {
override def hash(x: LocalTime): Int = x.hashCode
override def compare(x: LocalTime, y: LocalTime): Int = x.compareTo(y)
override def show(x: LocalTime): String = x.format(ISO_LOCAL_TIME)
}
}

object localtime extends localtime
object localtime extends localtime

Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import java.util.Locale
import cats.{Hash, Order, Show}

trait month {
implicit final val monthInstances = new Show[Month] with Order[Month] with Hash[Month] {
def compare(x: Month, y: Month): Int = x.compareTo(y)
implicit final val monthInstances: Show[Month] with Order[Month] with Hash[Month] =
new Show[Month] with Order[Month] with Hash[Month] {
def compare(x: Month, y: Month): Int = x.compareTo(y)

def hash(x: Month): Int = x.hashCode
def hash(x: Month): Int = x.hashCode

def show(t: Month): String = t.getDisplayName(TextStyle.SHORT, Locale.ENGLISH)
}
def show(t: Month): String = t.getDisplayName(TextStyle.SHORT, Locale.ENGLISH)
}
}

object month extends month
10000
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package io.chrisdavenport.cats.time.instances
import java.time.MonthDay
import java.time.format.DateTimeFormatter

import cats.{ Hash, Order, Show }
import cats.{Hash, Order, Show}

trait monthday {
implicit final val monthdayInstances =
implicit final val monthdayInstances: Show[MonthDay] with Order[MonthDay] with Hash[MonthDay] =
new Show[MonthDay] with Order[MonthDay] with Hash[MonthDay] {
def compare(x: MonthDay, y: MonthDay): Int = x.compareTo(y)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ trait offsetdatetime {
final def showOffsetDateTime(formatter: DateTimeFormatter): Show[OffsetDateTime] =
Show[String].contramap(_.format(formatter))

implicit final val offsetdatetimeInstances =
new Show[OffsetDateTime] with Order[OffsetDateTime] with Hash[OffsetDateTime]{
implicit final val offsetdatetimeInstances: Show[OffsetDateTime]
with Order[OffsetDateTime]
with Hash[OffsetDateTime] =
new Show[OffsetDateTime] with Order[OffsetDateTime] with Hash[OffsetDateTime] {
override def hash(x: OffsetDateTime): Int = x.hashCode
override def compare(x: OffsetDateTime, y: OffsetDateTime): Int = x.compareTo(y)
override def show(x: OffsetDateTime): String = x.format(ISO_OFFSET_DATE_TIME)
}
}

object offsetdatetime extends offsetdatetime
object offsetdatetime extends offsetdatetime

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ trait offsettime {
final def showOffsetTime(formatter: DateTimeFormatter): Show[OffsetTime] =
Show[String].contramap(_.format(formatter))

implicit final val offsettimeInstances =
new Show[OffsetTime] with Order[OffsetTime] with Hash[OffsetTime]{
implicit final val offsettimeInstances: Show[OffsetTime]
with Order[OffsetTime]
with Hash[OffsetTime] =
new Show[OffsetTime] with Order[OffsetTime] with Hash[OffsetTime] {
override def hash(x: OffsetTime): Int = x.hashCode
override def compare(x: OffsetTime, y: OffsetTime): Int = x.compareTo(y)
override def show(x: OffsetTime): String = x.format(ISO_OFFSET_TIME)
}

}

object offsettime extends offsettime
object offsettime extends offsettime

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import cats._
import java.time.Period

trait period {
implicit final val periodInstances =
new Show[Period]{
implicit final val periodInstances: Show[Period] =
new Show[Period] {
override def show(x: Period): String = x.toString
}
}

object period extends period
object period extends period

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import java.time.Year
import java.time.format.DateTimeFormatter

trait year {
implicit final val yearInstances =
new Show[Year] with Order[Year] with Hash[Year]{
implicit final val yearInstances: Show[Year] with Order[Year] with Hash[Year] =
new Show[Year] with Order[Year] with Hash[Year] {
override def hash(x: Year): Int = x.hashCode
override def compare(x: Year, y: Year): Int = x.compareTo(y)
override def show(x: Year): String = x.format(DateTimeFormatter.ofPattern("yyyy"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ trait yearmonth {

private final val yearMonthFormatter = DateTimeFormatter.ofPattern("yyyy-MM")

implicit final val yearmonthInstances =
new Show[YearMonth] with Order[YearMonth] with Hash[YearMonth]{
implicit final val yearmonthInstances: Show[YearMonth]
with Order[YearMonth]
with Hash[YearMonth] =
new Show[YearMonth] with Order[YearMonth] with Hash[YearMonth] {
override def hash(x: YearMonth): Int = x.hashCode
override def compare(x: YearMonth, y: YearMonth): Int = x.compareTo(y)
override def show(x: YearMonth): String = x.format(yearMonthFormatter)
}
}

object yearmonth extends yearmonth
object yearmonth extends yearmonth

Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ trait zoneddatetime {
final def showZonedDateTime(formatter: DateTimeFormatter): Show[ZonedDateTime] =
Show[String].contramap(_.format(formatter))

implicit final val zoneddatetimeInstances =
new Hash[ZonedDateTime] with Order[ZonedDateTime] with Show[ZonedDateTime]{
implicit final val zoneddatetimeInstances: Hash[ZonedDateTime]
with Order[ZonedDateTime]
with Show[ZonedDateTime] =
new Hash[ZonedDateTime] with Order[ZonedDateTime] with Show[ZonedDateTime] {
override def hash(x: ZonedDateTime): Int = x.hashCode
override def compare(x: ZonedDateTime, y: ZonedDateTime): Int = x.compareTo(y)
override def show(x: ZonedDateTime): String = x.format(ISO_ZONED_DATE_TIME)
}
}

object zoneddatetime extends zoneddatetime
object zoneddatetime extends zoneddatetime

Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import cats._
import java.time.ZoneId

trait zoneid {
implicit final val zoneidInstances =
new Show[ZoneId] with Eq[ZoneId] with Hash[ZoneId]{
implicit final val zoneidInstances: Show[ZoneId] with Eq[ZoneId] with Hash[ZoneId] =
new Show[ZoneId] with Eq[ZoneId] with Hash[ZoneId] {
override def eqv(x: ZoneId, y: ZoneId): Boolean = x.equals(y)
override def hash(x: ZoneId): Int = x.hashCode
override def show(x: ZoneId): String = x.getId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import cats._
import java.time.ZoneOffset

trait zoneoffset {
implicit final val zoneoffsetInstances =
new Show[ZoneOffset] with Order[ZoneOffset] with Hash[ZoneOffset]{
implicit final val zoneoffsetInstances: Show[ZoneOffset]
with Order[ZoneOffset]
with Hash[ZoneOffset] =
new Show[ZoneOffset] with Order[ZoneOffset] with Hash[ZoneOffset] {
override def hash(x: ZoneOffset): Int = x.hashCode
override def compare(x: ZoneOffset, y: ZoneOffset): Int = x.compareTo(y)
override def show(x: ZoneOffset): String = x.getId
Expand Down
Loading
0