8000 Regional configs by arainko · Pull Request #109 · arainko/ducktape · GitHub
[go: up one dir, main page]

Skip to content
Merged
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ metals.sbt
target/
sbt-launch.jar
ast_pretty_printed.*
project/project/build.properties
project/project/project/build.properties
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ val domainPerson = wirePerson.to[domain.Person]
// Card(
// name = "J. Doe",
// digits = 12345L,
// expires = 2023-12-18T15:00:25.065351Z
// expires = 2023-12-30T15:39:54.297957841Z
// )
// ),
// updatedAt = Some(value = 1970-01-01T00:00:00Z)
Expand Down Expand Up @@ -201,7 +201,7 @@ val domainPerson =
// Card(
// name = "CONST NAME",
// digits = 12345L,
// expires = 2023-12-18T15:00:25.078582Z
// expires = 2023-12-30T15:39:54.306592168Z
// )
// ),
// updatedAt = Some(value = 1970-01-01T00:00:00Z)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ object Field {
@compileTimeOnly("Field.default is only useable as a field configuration for transformations")
def default[A, B, FieldType](selector: Selector ?=> B => FieldType): Field[A, B] = ???

@compileTimeOnly("Field.fallbackToNone is only useable as a field configuration for transformations")
def fallbackToNone[A, B]: Field[A, B] & Regional = ???

@compileTimeOnly("Field.fallbackToDefault is only useable as a field configuration for transformations")
def fallbackToDefault[A, B]: Field[A, B] & Regional = ???

@compileTimeOnly("Field.allMatching is only useable as a field configuration for transformations")
def allMatching[A, B, DestFieldTpe, ProductTpe](selector: Selector ?=> B => DestFieldTpe, product: ProductTpe): Field[A, B] =
???
Expand Down
12 changes: 12 additions & 0 deletions ducktape/src/main/scala/io/github/arainko/ducktape/Regional.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.arainko.ducktape

import scala.annotation.compileTimeOnly

type Regional

object Regional {
extension [F[a, b] <: (Case[b, a] | Field[a, b]), A, B](self: F[A, B] & Regional) {
@compileTimeOnly(".regional is only usable as field configuration for transformations")
def regional[DestFieldTpe](selector: Selector ?=> B => DestFieldTpe): F[A, B] = ???
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.github.arainko.ducktape.internal

import scala.collection.mutable.Builder

opaque type Accumulator[A] = Builder[A, List[A]]

object Accumulator {

inline def use[A]: [B] => (f: Accumulator[A] ?=> B) => (List[A], B) =
[B] =>
(f: Accumulator[A] ?=> B) => {
val builder = List.newBuilder[A]
val result = f(using builder)
builder.result() -> result
}

inline def append[A](value: A)(using acc: Accumulator[A]): A = {
acc.addOne(value)
value
}
}
Loading
0