Skip to content

Commit

Permalink
build: Upgrade to Scala 3.4.3 (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
Iltotore authored Aug 29, 2024
1 parent 8850124 commit a617545
Show file tree
Hide file tree
Showing 26 changed files with 170 additions and 124 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
*.iml
tmp
out
.history
.history
sandbox
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.11.7
0.11.12
8 changes: 4 additions & 4 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import mill._, define._, api.Result
import scalalib._, scalalib.scalafmt._, scalalib.publish._, scalajslib._, scalanativelib._

object versions {
val scala = "3.3.1"
val scalaJS = "1.13.2"
val scalaNative = "0.4.15"
val scala = "3.4.3"
val scalaJS = "1.16.0"
val scalaNative = "0.4.17"
}

trait BaseModule extends ScalaModule with ScalafmtModule with CiReleaseModule { outer =>
Expand Down Expand Up @@ -291,7 +291,7 @@ object cats extends SubModule {
object test extends Tests {
def ivyDeps = Agg(
ivy"com.lihaoyi::utest:0.8.1",
ivy"org.typelevel::kittens:3.0.0"
ivy"org.typelevel::kittens:3.4.0"
)
}

Expand Down
9 changes: 4 additions & 5 deletions cats/test/src/io/github/iltotore/iron/CatsSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ object CatsSuite extends TestSuite:
test("validatedNel"):
test - assert(valid.refineAllValidatedNel[Positive] == Valid(valid))
test - assert(invalid.refineAllValidatedNel[Positive] == Invalid(NonEmptyList.of(
InvalidValue(-2, "Should be strictly positive"),
InvalidValue(-3, "Should be strictly positive")
)))
InvalidValue(-2, "Should be strictly positive"),
InvalidValue(-3, "Should be strictly positive")
)))

test("further"):

Expand Down Expand Up @@ -231,6 +231,5 @@ object CatsSuite extends TestSuite:
InvalidValue(-2, "Should be strictly positive"),
InvalidValue(-3, "Should be strictly positive")
)))



}
4 changes: 2 additions & 2 deletions docs/_docs/modules/cats.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ import io.github.iltotore.iron.*
import io.github.iltotore.iron.cats.*
import io.github.iltotore.iron.constraint.all.*
//}
type Username = Alphanumeric DescribedAs "Username should be alphanumeric"
type Username = DescribedAs[Alphanumeric, "Username should be alphanumeric"]

type Age = Positive DescribedAs "Age should be positive"
type Age = DescribedAs[Positive, "Age should be positive"]

case class User(name: String :| Username, age: Int :| Age)

Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/modules/circe.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ import io.github.iltotore.iron.*
import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.circe.given

type Username = Alphanumeric DescribedAs "Username should be alphanumeric"
type Username = DescribedAs[Alphanumeric, "Username should be alphanumeric"]

type Age = Positive DescribedAs "Age should be positive"
type Age = DescribedAs[Positive, "Age should be positive"]

case class User(name: String :| Username, age: Int :| Age)

Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/modules/zio.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.zio.*


type Username = Alphanumeric DescribedAs "Username should be alphanumeric"
type Username = DescribedAs[Alphanumeric, "Username should be alphanumeric"]

type Age = Positive DescribedAs "Age should be positive"
type Age = DescribedAs[Positive, "Age should be positive"]

case class User(name: String :| Username, age: Int :| Age)

Expand Down
4 changes: 2 additions & 2 deletions docs/_docs/reference/refinement.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.zio.*


type Username = Alphanumeric DescribedAs "Username should be alphanumeric"
type Username = DescribedAs[Alphanumeric, "Username should be alphanumeric"]

type Age = Positive DescribedAs "Age should be positive"
type Age = DescribedAs[Positive, "Age should be positive"]

case class User(name: String :| Username, age: Int :| Age)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import io.github.iltotore.iron.constraint.all.*
import io.github.iltotore.iron.*
import io.github.iltotore.iron.borer.given // this enables borer <-> iron integration

type Username = (Alphanumeric & MinLength[3] & MaxLength[10]) DescribedAs
type Username = DescribedAs[
Alphanumeric & MinLength[3] & MaxLength[10],
"Username should be alphanumeric and have a length between 3 and 10"
]

type Password = (Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20]) DescribedAs
type Password = DescribedAs[
Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20],
"Password must contain at least a letter, a digit and have a length between 6 and 20"
]

type Age = Greater[0] DescribedAs
"Age should be strictly positive"
type Age = DescribedAs[Greater[0], "Age should be strictly positive"]

case class Account(
name: String :| Username,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import io.github.iltotore.iron.constraint.all.*
import org.http4s.{EntityDecoder, EntityEncoder}
import org.http4s.circe.*

type Username = (Alphanumeric & MinLength[3] & MaxLength[10]) DescribedAs
type Username = DescribedAs[
Alphanumeric & MinLength[3] & MaxLength[10],
"Username should be alphanumeric and have a length between 3 and 10"
]

type Password = (Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20]) DescribedAs
type Password = DescribedAs[
Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20],
"Password must contain atleast a letter, a digit and have a length between 6 and 20"
]

type Age = Greater[0] DescribedAs "Age should be strictly positive"
type Age = DescribedAs[Greater[0], "Age should be strictly positive"]

/**
* A basic Account with a name, a password and an age.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ import io.github.iltotore.iron.{*, given}

import scala.util.Try

type Username = (Alphanumeric & MinLength[3] & MaxLength[10]) DescribedAs
type Username = DescribedAs[
Alphanumeric & MinLength[3] & MaxLength[10],
"Username should be alphanumeric and have a length between 3 and 10"
]

type Password = (Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20]) DescribedAs
type Password = DescribedAs[
Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20],
"Password must contain atleast a letter, a digit and have a length between 6 and 20"
]

type Age = Greater[0] DescribedAs "Age should be strictly positive"
type Age = DescribedAs[Greater[0], "Age should be strictly positive"]

/**
* A basic Account with a name, a password and an age.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import io.github.iltotore.iron.zioJson.given

import zio.json.*

type Username = (Alphanumeric & MinLength[3] & MaxLength[10]) DescribedAs
type Username = DescribedAs[
Alphanumeric & MinLength[3] & MaxLength[10],
"Username should be alphanumeric and have a length between 3 and 10"
]

type Password = (Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20]) DescribedAs
type Password = DescribedAs[
Match["[A-Za-z].*[0-9]|[0-9].*[A-Za-z]"] & MinLength[6] & MaxLength[20],
"Password must contain atleast a letter, a digit and have a length between 6 and 20"
]

type Age = Greater[0] DescribedAs "Age should be strictly positive"
type Age = DescribedAs[Greater[0], "Age should be strictly positive"]

/**
* A basic Account with a name, a password and an age.
Expand Down
2 changes: 1 addition & 1 deletion main/src/io/github/iltotore/iron/RefinedTypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,4 @@ object RefinedTypeOps:
* //FinalType =/= IronType
* }}}
*/
type FinalType = T
type FinalType = T
6 changes: 3 additions & 3 deletions main/src/io/github/iltotore/iron/constraint/any.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object any:
* @tparam V the description to attach.
* @example {{{
* //Literal
* type PosInt = Greater[0] DescribedAs "Should be positive"
* type PosInt = DescribedAs[Greater[0], "Should be positive"]
*
* //Using type-level String concatenation (example taken from `numeric`)
* import io.github.iltotore.iron.ops.*
Expand Down Expand Up @@ -123,12 +123,12 @@ object any:
/**
* A described constraint C1 implies C1.
*/
given [C1, C2, V <: String](using C1 ==> C2): ((C1 DescribedAs V) ==> C2) = Implication()
given [C1, C2, V <: String](using C1 ==> C2): (DescribedAs[C1, V] ==> C2) = Implication()

/**
* A constraint C1 implies its "described" form.
*/
given [C1, C2, V <: String](using C1 ==> C2): (C1 ==> (C2 DescribedAs V)) = Implication()
given [C1, C2, V <: String](using C1 ==> C2): (C1 ==> DescribedAs[C2, V]) = Implication()

object Not:
class NotConstraint[A, C, Impl <: Constraint[A, C]](using Impl) extends Constraint[A, Not[C]]:
Expand Down
6 changes: 3 additions & 3 deletions main/src/io/github/iltotore/iron/constraint/char.scala
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object char:
private def check(expr: Expr[Char])(using Quotes): Expr[Boolean] =
val rflUtil = reflectUtil
import rflUtil.*

expr.decode match
case Right(value) => Expr(value.isUpper)
case _ => '{ $expr.isUpper }
Expand All @@ -98,7 +98,7 @@ object char:
private def check(expr: Expr[Char])(using Quotes): Expr[Boolean] =
val rflUtil = reflectUtil
import rflUtil.*

expr.decode match
case Right(value) => Expr(value.isDigit)
case _ => '{ $expr.isDigit }
Expand All @@ -114,7 +114,7 @@ object char:
private def check(expr: Expr[Char])(using Quotes): Expr[Boolean] =
val rflUtil = reflectUtil
import rflUtil.*

expr.decode match
case Right(value) => Expr(value.isLetter)
case _ => '{ $expr.isLetter }
12 changes: 6 additions & 6 deletions main/src/io/github/iltotore/iron/constraint/collection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,24 @@ object collection:
*
* @tparam V the minimum length of the tested input
*/
type MinLength[V <: Int] = Length[GreaterEqual[V]] DescribedAs "Should have a minimum length of " + V
type MinLength[V <: Int] = DescribedAs[Length[GreaterEqual[V]], "Should have a minimum length of " + V]

/**
* Tests maximum length. Supports [[Iterable]] and [[String]] by default.
*
* @tparam V the maximum length of the tested input
*/
type MaxLength[V <: Int] = Length[LessEqual[V]] DescribedAs "Should have a maximum length of " + V
type MaxLength[V <: Int] = DescribedAs[Length[LessEqual[V]], "Should have a maximum length of " + V]

/**
* Tests exact length. Supports [[Iterable]] and [[String]] by default.
*/
type FixedLength[V <: Int] = Length[StrictEqual[V]] DescribedAs "Should have an exact length of " + V
type FixedLength[V <: Int] = DescribedAs[Length[StrictEqual[V]], "Should have an exact length of " + V]

/**
* Tests if the input is empty.
*/
type Empty = FixedLength[0] DescribedAs "Should be empty"
type Empty = DescribedAs[FixedLength[0], "Should be empty"]

/**
* Tests if the given collection contains a specific value.
Expand Down Expand Up @@ -117,7 +117,7 @@ object collection:

expr.decode match
case Right(value) => applyConstraint(Expr(value.length), constraintExpr)
case _ => applyConstraint('{ $expr.length }, constraintExpr)
case _ => applyConstraint('{ $expr.length }, constraintExpr)

given [C1, C2](using C1 ==> C2): (Length[C1] ==> Length[C2]) = Implication()

Expand All @@ -140,7 +140,7 @@ object collection:

(expr.decode, partExpr.decode) match
case (Right(value), Right(part)) => Expr(value.contains(part))
case _ => '{ ${ expr }.contains($partExpr) }
case _ => '{ ${ expr }.contains($partExpr) }

object ForAll:

Expand Down
38 changes: 28 additions & 10 deletions main/src/io/github/iltotore/iron/constraint/numeric.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,40 @@ object numeric:
*
* @tparam V the value the input must be greater than or equal to.
*/
type GreaterEqual[V] = (Greater[V] | StrictEqual[V]) DescribedAs ("Should be greater than or equal to " + V)
type GreaterEqual[V] = DescribedAs[
Greater[V] | StrictEqual[V],
"Should be greater than or equal to " + V
]

/**
* Tests non-strict inferiority.
*
* @tparam V the value the input must be less than or equal to.
*/
type LessEqual[V] = (Less[V] | StrictEqual[V]) DescribedAs ("Should be less than or equal to " + V)
type LessEqual[V] = DescribedAs[
Less[V] | StrictEqual[V],
"Should be less than or equal to " + V
]

/**
* Tests if the input is strictly positive.
*/
type Positive = Greater[0] DescribedAs "Should be strictly positive"
type Positive = DescribedAs[Greater[0], "Should be strictly positive"]

/**
* Tests if the input is positive or zero.
*/
type Positive0 = GreaterEqual[0] DescribedAs "Should be positive or zero"
type Positive0 = DescribedAs[GreaterEqual[0], "Should be positive or zero"]

/**
* Tests if the input is strictly negative.
*/
type Negative = Less[0] DescribedAs "Should be strictly negative"
type Negative = DescribedAs[Less[0], "Should be strictly negative"]

/**
* Tests if the input is negative or zero.
*/
type Negative0 = LessEqual[0] DescribedAs "Should be negative or zero"
type Negative0 = DescribedAs[LessEqual[0], "Should be negative or zero"]

object Interval:

Expand All @@ -67,31 +73,43 @@ object numeric:
* @tparam V1 the lower bound, exclusive.
* @tparam V2 the upper bound, exclusive.
*/
type Open[V1, V2] = (Greater[V1] & Less[V2]) DescribedAs ("Should be included in (" + V1 + ", " + V2 + ")")
type Open[V1, V2] = DescribedAs[
Greater[V1] & Less[V2],
"Should be included in (" + V1 + ", " + V2 + ")"
]

/**
* Tests if the input is included in `(V1, V2]`
*
* @tparam V1 the lower bound, exclusive.
* @tparam V2 the upper bound, inclusive.
*/
type OpenClosed[V1, V2] = (Greater[V1] & LessEqual[V2]) DescribedAs ("Should be included in (" + V1 + ", " + V2 + "]")
type OpenClosed[V1, V2] = DescribedAs[
Greater[V1] & LessEqual[V2],
"Should be included in (" + V1 + ", " + V2 + "]"
]

/**
* Tests if the input is included in `[V1, V2)`
*
* @tparam V1 the lower bound, inclusive.
* @tparam V2 the upper bound, exclusive.
*/
type ClosedOpen[V1, V2] = (GreaterEqual[V1] & Less[V2]) DescribedAs ("Should be included in [" + V1 + ", " + V2 + ")")
type ClosedOpen[V1, V2] = DescribedAs[
GreaterEqual[V1] & Less[V2],
"Should be included in [" + V1 + ", " + V2 + ")"
]

/**
* Tests if the input is included in `[V1, V2]`
*
* @tparam V1 the lower bound, inclusive.
* @tparam V2 the upper bound, inclusive.
*/
type Closed[V1, V2] = (GreaterEqual[V1] & LessEqual[V2]) DescribedAs ("Should be included in [" + V1 + ", " + V2 + "]")
type Closed[V1, V2] = DescribedAs[
GreaterEqual[V1] & LessEqual[V2],
"Should be included in [" + V1 + ", " + V2 + "]"
]

/**
* Tests if the input is a multiple of V.
Expand Down
Loading

0 comments on commit a617545

Please sign in to comment.