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

coulomb-runtime for scala3 #420

Merged
merged 141 commits into from
Sep 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
22a54c1
fix merge conflict
erikerlandson Jan 14, 2023
bf86408
reformat build.sbt
erikerlandson Jan 14, 2023
207510c
parser.scala
erikerlandson Jan 14, 2023
25a4a22
toVersionIntroduced
erikerlandson Jan 14, 2023
b27d991
test f
erikerlandson Jan 14, 2023
99133c8
reformat
erikerlandson Jan 14, 2023
ec53904
expr of map
erikerlandson Jan 14, 2023
08d459f
test of runtime TypeRepr build (not working)
erikerlandson Jan 15, 2023
cec9f64
closer
erikerlandson Jan 15, 2023
df81ac0
hardcode import works
erikerlandson Jan 18, 2023
c8a1af4
poc string to TypeRef
erikerlandson Jan 22, 2023
2a98715
fqTypeRepr
erikerlandson Jan 22, 2023
de17011
symbolValueType
erikerlandson Jan 26, 2023
2722669
UnitAST
erikerlandson Jan 29, 2023
b43d85b
widen
erikerlandson Jan 31, 2023
e7c266e
astTypeRepr
erikerlandson Jan 31, 2023
31fb3ad
kernel
erikerlandson Jan 31, 2023
34bd462
bridge static -> runtime
erikerlandson Jan 31, 2023
fbc69c1
withUnitRuntime
erikerlandson Jan 31, 2023
34a1aad
UnitAST -> RuntimeUnit, return Either
erikerlandson Feb 1, 2023
c067964
add some annotation ideas
erikerlandson Feb 1, 2023
91f9257
RuntimeQuantity
erikerlandson Feb 1, 2023
189e46e
bump version-introduced
erikerlandson Feb 2, 2023
6274133
align RuntimeQuantity with Quantity
erikerlandson Feb 3, 2023
6ea4503
given staging.Compiler from above
erikerlandson Feb 3, 2023
2a963ee
RuntimeUnit toString
erikerlandson Feb 3, 2023
a71dfb4
RuntimeUnit toString
erikerlandson Feb 3, 2023
0bea9c7
units % Test
erikerlandson Feb 3, 2023
f1f5960
JVM only. SAD.
erikerlandson Feb 4, 2023
1e383ff
are you kidding me?
erikerlandson Feb 4, 2023
cb18314
formatting troll
erikerlandson Feb 4, 2023
17a3aa4
more formatting troll
erikerlandson Feb 4, 2023
e26d094
refactor to CoefficientRuntime
erikerlandson Feb 5, 2023
b35035c
StagingCoefficientRuntime class
erikerlandson Feb 6, 2023
df20eaa
stub MappingCoefficientRuntime
erikerlandson Feb 6, 2023
9472c66
UnitConst
erikerlandson Feb 7, 2023
f99d32f
Canonical - missing base unit and derived unit awareness
erikerlandson Feb 10, 2023
4d4801d
factor runtime meta to meta.scala
erikerlandson Feb 10, 2023
ca11425
staging.scala
erikerlandson Feb 10, 2023
68938c6
mapping.scala
erikerlandson Feb 10, 2023
bc4a139
refactor canonical
erikerlandson Feb 11, 2023
6ba1cc7
clean up signature of canonical to use Either
erikerlandson Feb 11, 2023
3777937
utlClosure
erikerlandson Feb 11, 2023
0796365
refactor derivedunit method
erikerlandson Feb 11, 2023
f8c8f65
working draft of MappingCoefficientRuntime
erikerlandson Feb 11, 2023
4cfdaad
stagingquantity.scala
erikerlandson Feb 11, 2023
5dad792
fix inverted coef ratio
erikerlandson Feb 11, 2023
f12abf6
fix inverted coef ratio
erikerlandson Feb 11, 2023
20b3fe9
MappingRuntimeQuantitySuite and JS+Native builds
erikerlandson Feb 11, 2023
33df4a6
support module names
erikerlandson Feb 12, 2023
b995750
either testing predicates
erikerlandson Feb 14, 2023
6eac8da
factor RuntimeQuantitySuite
erikerlandson Feb 14, 2023
7fe2150
format
erikerlandson Feb 14, 2023
3122340
RuntimeAdd
erikerlandson Feb 18, 2023
0f9c703
format
erikerlandson Feb 18, 2023
6313001
addition
erikerlandson Feb 19, 2023
6c1affc
runtime policies
erikerlandson Feb 19, 2023
adca749
standard addition
erikerlandson Feb 19, 2023
ad8d7ef
add some syntax options
erikerlandson Feb 23, 2023
5e9658d
stub coulomb-pureconfig
erikerlandson Feb 25, 2023
b601c59
ConfigReader[RuntimeUnit]
erikerlandson Feb 25, 2023
8dbafc6
ConfigReader[RuntimeUnit] and ConfigWriter[RuntimeUnit]
erikerlandson Feb 26, 2023
10aaa11
stub coulomb-parser
erikerlandson Mar 1, 2023
0ac6602
move &: and TNil to syntax
erikerlandson Mar 4, 2023
a9ce999
fix typelist import
erikerlandson Mar 4, 2023
93ef801
factor typeReprList
erikerlandson Mar 4, 2023
98f6c03
removed duplicate
erikerlandson Mar 4, 2023
d1b69e2
baseunitTR
erikerlandson Mar 4, 2023
c12e6dd
private utlClosure
erikerlandson Mar 4, 2023
a09b742
collect and strset
erikerlandson Mar 4, 2023
f7287c9
format
erikerlandson Mar 4, 2023
d70bf58
optimze with void
erikerlandson Mar 5, 2023
bc6d01e
foldLeft
erikerlandson Mar 5, 2023
ee79a2f
parse named units
erikerlandson Mar 5, 2023
20205ca
parse returns Either
erikerlandson Mar 5, 2023
f2eb856
oneOf
erikerlandson Mar 5, 2023
57ad68e
mul not working
erikerlandson Mar 5, 2023
010ae71
play with chainl1 (not working)
erikerlandson Mar 7, 2023
07b7446
chainl1 and named working correctly
erikerlandson Mar 8, 2023
cd783b3
complete unit expression grammar
erikerlandson Mar 8, 2023
1474272
replace &: with scala *:
erikerlandson Mar 10, 2023
385f85c
format
erikerlandson Mar 11, 2023
d13083a
factor toRational
erikerlandson Mar 11, 2023
4f2333d
render
erikerlandson Mar 11, 2023
28e670d
factor parsing
erikerlandson Mar 11, 2023
99c1c36
factor meta
erikerlandson Mar 11, 2023
8526e42
parsing.scala
erikerlandson Mar 11, 2023
5546c2c
ConfigReader[Quantity[U, V]]
erikerlandson Mar 12, 2023
d369bd6
remove hierarchy pattern example
erikerlandson Mar 12, 2023
ca31c89
ConfigWriter[Quantity[V, U]]
erikerlandson Mar 12, 2023
c20304f
Rational polymorphic i/o
erikerlandson Mar 14, 2023
c3805b4
factor pureconfig readers and writers into policies
erikerlandson Aug 6, 2023
3fac01c
factor out dsl to dsl.scala
erikerlandson Aug 6, 2023
0aa98cc
fix new dsl path
erikerlandson Aug 6, 2023
e9d3845
rename to RuntimeUnitDslParser
erikerlandson Aug 6, 2023
fa73afc
PureconfigRuntime
erikerlandson Aug 6, 2023
d13e283
bump tlVersionIntroduced to 0.8.0
erikerlandson Aug 6, 2023
f604b75
factor into io and policy
erikerlandson Aug 8, 2023
e7f347a
skeleton unit testing
erikerlandson Aug 12, 2023
1bf3a8c
add parser and pureconfig to root proj
erikerlandson Aug 12, 2023
c7d3fd3
scalafmt updates
erikerlandson Aug 12, 2023
6ff7f7b
disable js and native platforms for parser and pureconfig
erikerlandson Aug 12, 2023
a574952
testing skeleton for parser
erikerlandson Aug 12, 2023
2666b46
scalafmt
erikerlandson Aug 12, 2023
496c19b
parser builds for JS and Native
erikerlandson Aug 12, 2023
f0de8e5
wip json io for RuntimeUnit
erikerlandson Aug 13, 2023
28925f4
smoke test JSON RuntimeUnit reader
erikerlandson Aug 13, 2023
8fef20d
add exponent op to json reader
erikerlandson Aug 14, 2023
f575c15
json writer for runtime unit
erikerlandson Aug 14, 2023
f5a4dee
remove operator addition example
erikerlandson Aug 16, 2023
807388d
add case for no value conversion
erikerlandson Aug 16, 2023
e82cee4
factor to runtimeq
erikerlandson Aug 16, 2023
bd80c00
remove ops from unit tests
erikerlandson Aug 16, 2023
335583d
resync ci.yml
erikerlandson Aug 26, 2023
9fcfb05
stub out coulomb-pureconfig doc
erikerlandson Sep 4, 2023
9c28688
add note about publish to s01.oss.sonatype.org
erikerlandson Sep 6, 2023
d1de6f6
quick start example
erikerlandson Sep 6, 2023
c1fcadb
dealias to get consistent mappings
erikerlandson Sep 10, 2023
566852b
case class Config example
erikerlandson Sep 10, 2023
9d09c65
improve definition of ConfigReader for case class
erikerlandson Sep 10, 2023
fbd1156
io policy section
erikerlandson Sep 10, 2023
e3965e0
integer i/o section
erikerlandson Sep 12, 2023
018c1ea
stub coulomb-runtime docs
erikerlandson Sep 13, 2023
45c5399
stub coulomb-parser docs
erikerlandson Sep 16, 2023
dc6e5fc
add note about pureconfig and jvm only
erikerlandson Sep 16, 2023
512f99e
some parsing example code
erikerlandson Sep 16, 2023
a225e8b
add laika conf to support @:api
erikerlandson Sep 17, 2023
2804e1e
add external target for Quantity typedef
erikerlandson Sep 23, 2023
0098d09
fix formatting
erikerlandson Sep 23, 2023
cdb5d99
documented example code for coulomb-parser
erikerlandson Sep 23, 2023
56e4be9
add laika pr ref
erikerlandson Sep 23, 2023
f82ff67
add explaination
erikerlandson Sep 23, 2023
c0fe7b8
add coulomb package prefix
erikerlandson Sep 23, 2023
c262a1c
format troll
erikerlandson Sep 24, 2023
08cf0ba
add scala 3 api links
erikerlandson Sep 24, 2023
0e61ade
more coulomb-parser doc
erikerlandson Sep 24, 2023
497b126
predefine doc page links
erikerlandson Sep 24, 2023
590d12d
quick start for coulomb-runtime
erikerlandson Sep 24, 2023
8cf593b
doc massaging
erikerlandson Sep 30, 2023
93e3428
clean up link definitions
erikerlandson Sep 30, 2023
3f6db6d
modernize links
erikerlandson Sep 30, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ jobs:

- name: Make target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/scala3')
run: mkdir -p spire/.js/target spire/.jvm/target testkit/.native/target units/.jvm/target testkit/.js/target unidocs/target core/.native/target spire/.native/target core/.js/target units/.native/target core/.jvm/target refined/.native/target refined/.js/target refined/.jvm/target units/.js/target testkit/.jvm/target project/target
run: mkdir -p runtime/.js/target spire/.js/target spire/.jvm/target testkit/.native/target units/.jvm/target runtime/.native/target testkit/.js/target parser/.jvm/target unidocs/target parser/.js/target core/.native/target pureconfig/.jvm/target spire/.native/target parser/.native/target core/.js/target units/.native/target runtime/.jvm/target core/.jvm/target refined/.native/target refined/.js/target refined/.jvm/target units/.js/target testkit/.jvm/target project/target

- name: Compress target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/scala3')
run: tar cf targets.tar spire/.js/target spire/.jvm/target testkit/.native/target units/.jvm/target testkit/.js/target unidocs/target core/.native/target spire/.native/target core/.js/target units/.native/target core/.jvm/target refined/.native/target refined/.js/target refined/.jvm/target units/.js/target testkit/.jvm/target project/target
run: tar cf targets.tar runtime/.js/target spire/.js/target spire/.jvm/target testkit/.native/target units/.jvm/target runtime/.native/target testkit/.js/target parser/.jvm/target unidocs/target parser/.js/target core/.native/target pureconfig/.jvm/target spire/.native/target parser/.native/target core/.js/target units/.native/target runtime/.jvm/target core/.jvm/target refined/.native/target refined/.js/target refined/.jvm/target units/.js/target testkit/.jvm/target project/target

- name: Upload target directories
if: github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/scala3')
Expand Down
177 changes: 175 additions & 2 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
ThisBuild / tlBaseVersion := "0.7"

// publish settings
// artifacts now publish to s01.oss.sonatype.org, per:
// https://github.com/erikerlandson/coulomb/issues/500
ThisBuild / developers += tlGitHubDev("erikerlandson", "Erik Erlandson")
ThisBuild / organization := "com.manyangled"
ThisBuild / organizationName := "Erik Erlandson"
Expand Down Expand Up @@ -38,7 +40,17 @@ def commonSettings = Seq(
)

lazy val root = tlCrossRootProject
.aggregate(core, units, spire, refined, testkit, unidocs)
.aggregate(
core,
units,
runtime,
parser,
pureconfig,
spire,
refined,
testkit,
unidocs
)

lazy val core = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
Expand All @@ -60,6 +72,69 @@ lazy val units = crossProject(JVMPlatform, JSPlatform, NativePlatform)
libraryDependencies += "io.github.cquiroz" %%% "scala-java-time" % "2.5.0" % Test
)

// see also: https://github.com/lampepfl/dotty/issues/7647
lazy val runtime = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("runtime"))
.settings(name := "coulomb-runtime")
.dependsOn(
core % "compile->compile;test->test",
units % Test
)
.settings(
tlVersionIntroduced := Map("3" -> "0.8.0")
)
.settings(commonSettings: _*)
.settings(
// staging compiler is only supported on JVM
// but is also used to satisfy builds on JS and Native
libraryDependencies += "org.scala-lang" %% "scala3-staging" % scalaVersion.value
)
.platformsSettings(JSPlatform, NativePlatform)(
// any unit tests using staging must be excluded from JS and Native
Test / unmanagedSources / excludeFilter := HiddenFileFilter || "*stagingquantity.scala"
)

// cats-parse doesn't seem to build for JS or Native
lazy val parser = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("parser"))
.settings(name := "coulomb-parser")
.dependsOn(
core % "compile->compile;test->test",
runtime,
units % Test
)
.settings(
tlVersionIntroduced := Map("3" -> "0.8.0")
)
.settings(commonSettings: _*)
.settings(
libraryDependencies += "org.typelevel" %%% "cats-parse" % "0.3.10"
)

// pureconfig doesn't currently build for JS or Native
// https://github.com/pureconfig/pureconfig/issues/1307
lazy val pureconfig = crossProject(
JVMPlatform /*, JSPlatform, NativePlatform */
)
.crossType(CrossType.Pure)
.in(file("pureconfig"))
.settings(name := "coulomb-pureconfig")
.dependsOn(
core % "compile->compile;test->test",
runtime,
parser,
units % Test
)
.settings(
tlVersionIntroduced := Map("3" -> "0.8.0")
)
.settings(commonSettings: _*)
.settings(
libraryDependencies += "com.github.pureconfig" %%% "pureconfig-core" % "0.17.4"
)

lazy val spire = crossProject(JVMPlatform, JSPlatform, NativePlatform)
.crossType(CrossType.Pure)
.in(file("spire"))
Expand Down Expand Up @@ -102,6 +177,9 @@ lazy val all = project
.dependsOn(
core.jvm,
units.jvm,
runtime.jvm,
parser.jvm,
pureconfig.jvm,
spire.jvm,
refined.jvm
) // scala repl only needs JVMPlatform subproj builds
Expand All @@ -122,15 +200,110 @@ lazy val unidocs = project
// https://typelevel.org/sbt-typelevel/site.html
// sbt docs/tlSitePreview
// http://localhost:4242
import laika.ast.{ExternalTarget, InternalTarget, VirtualPath}
import laika.rewrite.link.{LinkConfig, ApiLinks, SourceLinks, TargetDefinition}
lazy val docs = project
.in(file("site"))
.dependsOn(core.jvm, units.jvm, spire.jvm, refined.jvm)
.dependsOn(
core.jvm,
units.jvm,
runtime.jvm,
parser.jvm,
pureconfig.jvm,
spire.jvm,
refined.jvm
)
.enablePlugins(TypelevelSitePlugin)
.settings(
// turn off the new -W warnings in mdoc scala compilations
// at least until I can get a better handle on how to work with them
Compile / scalacOptions ~= (_.filterNot { x => x.startsWith("-W") })
)
.settings(
laikaConfig := LaikaConfig.defaults
.withConfigValue(
LinkConfig.empty
.addApiLinks(
ApiLinks(
baseUri =
"https://www.javadoc.io/doc/com.manyangled/coulomb-docs_3/latest/",
packagePrefix = "coulomb"
),
ApiLinks(
baseUri = "https://scala-lang.org/api/3.x/",
packagePrefix = "scala"
),
ApiLinks(
baseUri =
"https://javadoc.io/doc/com.github.pureconfig/pureconfig-core_3/latest/",
packagePrefix = "pureconfig"
)
)
.addTargets(
// Target names need to be all lowercase.
// Note, this does not align with Laika docs.
// In future laika releases the names will be case insensitive, see:
// https://github.com/typelevel/Laika/pull/541
TargetDefinition(
// intended usage: [Quantity][quantitytypedef]
// Links to type defs do not work properly with laika '@:api(...)' constructs
// which is going to make a lot of coulomb references harder to do.
"quantitytypedef",
ExternalTarget(
"https://www.javadoc.io/doc/com.manyangled/coulomb-docs_3/latest/coulomb.html#Quantity[V,U]=V"
)
),
TargetDefinition(
"coulomb-introduction",
InternalTarget(
VirtualPath.parse("README.md")
)
),
TargetDefinition(
"coulomb-core",
InternalTarget(
VirtualPath.parse("coulomb-core.md")
)
),
TargetDefinition(
"coulomb-units",
InternalTarget(
VirtualPath.parse("coulomb-units.md")
)
),
TargetDefinition(
"coulomb-spire",
InternalTarget(
VirtualPath.parse("coulomb-spire.md")
)
),
TargetDefinition(
"coulomb-refined",
InternalTarget(
VirtualPath.parse("coulomb-refined.md")
)
),
TargetDefinition(
"coulomb-runtime",
InternalTarget(
VirtualPath.parse("coulomb-runtime.md")
)
),
TargetDefinition(
"coulomb-parser",
InternalTarget(
VirtualPath.parse("coulomb-parser.md")
)
),
TargetDefinition(
"coulomb-pureconfig",
InternalTarget(
VirtualPath.parse("coulomb-pureconfig.md")
)
)
)
)
)

// https://github.com/sbt/sbt-jmh
// sbt "benchmarks/Jmh/run .*Benchmark"
Expand Down
69 changes: 54 additions & 15 deletions core/src/main/scala/coulomb/infra/meta.scala
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,49 @@ object meta:

object baseunit:
def unapply(using Quotes)(u: quotes.reflect.TypeRepr): Boolean =
u match
case baseunitTR(_) => true
case _ => false

object derivedunit:
def unapply(using qq: Quotes, mode: SigMode)(
u: quotes.reflect.TypeRepr
): Option[(Rational, List[(quotes.reflect.TypeRepr, Rational)])] =
import quotes.reflect.*
u match
case derivedunitTR(dtr) =>
mode match
case SigMode.Simplify =>
// don't expand the signature definition in simplify mode
Some((Rational.const1, (u, Rational.const1) :: Nil))
case _ =>
val AppliedType(_, List(_, d, _, _)) =
dtr: @unchecked
Some(cansig(d))
case _ => None

object baseunitTR:
def unapply(using Quotes)(
u: quotes.reflect.TypeRepr
): Option[quotes.reflect.TypeRepr] =
import quotes.reflect.*
Implicits.search(
TypeRepr
.of[BaseUnit]
.appliedTo(List(u, TypeBounds.empty, TypeBounds.empty))
) match
case iss: ImplicitSearchSuccess => true
case _ => false
case iss: ImplicitSearchSuccess =>
Some(
iss.tree.tpe.baseType(
TypeRepr.of[BaseUnit].typeSymbol
)
)
case _ => None

object derivedunit:
def unapply(using qq: Quotes, mode: SigMode)(
object derivedunitTR:
def unapply(using Quotes)(
u: quotes.reflect.TypeRepr
): Option[(Rational, List[(quotes.reflect.TypeRepr, Rational)])] =
): Option[quotes.reflect.TypeRepr] =
import quotes.reflect.*
Implicits.search(
TypeRepr
Expand All @@ -290,16 +320,11 @@ object meta:
)
) match
case iss: ImplicitSearchSuccess =>
mode match
case SigMode.Simplify =>
// don't expand the signature definition in simplify mode
Some((Rational.const1, (u, Rational.const1) :: Nil))
case _ =>
val AppliedType(_, List(_, d, _, _)) =
iss.tree.tpe.baseType(
TypeRepr.of[DerivedUnit].typeSymbol
): @unchecked
Some(cansig(d))
Some(
iss.tree.tpe.baseType(
TypeRepr.of[DerivedUnit].typeSymbol
)
)
case _ => None

object deltaunit:
Expand Down Expand Up @@ -360,6 +385,20 @@ object meta:
case Nil => Nil
case (u, e0) :: tail => (u, e0 * e) :: unifyPow(e, tail)

def typeReprList(using Quotes)(
tlist: quotes.reflect.TypeRepr
): List[quotes.reflect.TypeRepr] =
import quotes.reflect.*
tlist match
case tnil if (tnil =:= TypeRepr.of[EmptyTuple]) => Nil
case AppliedType(t, List(head, tail)) if (t =:= TypeRepr.of[*:]) =>
head :: typeReprList(tail)
case _ =>
report.errorAndAbort(
s"typeReprList: bad type list ${tlist.show}"
)
null.asInstanceOf[Nothing]

def typestr(using Quotes)(t: quotes.reflect.TypeRepr): String =
// The policy goal here is that type aliases are never expanded.
typestring(t, false)
Expand Down
29 changes: 13 additions & 16 deletions core/src/main/scala/coulomb/ops/ops.scala
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ object ValuePromotion:
import scala.quoted.*
import scala.language.implicitConversions

import coulomb.infra.meta.typestr

final type &:[H, T]
final type TNil
import coulomb.infra.meta.*

transparent inline given ctx_VP_Path[VF, VT]: ValuePromotion[VF, VT] = ${
vpPath[VF, VT]
Expand Down Expand Up @@ -206,20 +203,19 @@ object ValuePromotion:
iss.tree.tpe.baseType(
TypeRepr.of[ValuePromotionPolicy].typeSymbol
): @unchecked
vpp2str(vppt)
vpp2str(typeReprList(vppt))
case _ =>
report.error("no ValuePromotionPolicy was found in scope")
VppSet.empty[(String, String)]
null.asInstanceOf[Nothing]

private def vpp2str(using Quotes)(
vpp: quotes.reflect.TypeRepr
vppl: List[quotes.reflect.TypeRepr]
): VppSet[(String, String)] =
import quotes.reflect.*
vpp match
case t if (t =:= TypeRepr.of[TNil]) =>
VppSet.empty[(String, String)]
case AppliedType(v, List(AppliedType(t2, List(vf, vt)), tail))
if ((v =:= TypeRepr.of[&:]) && (t2 =:= TypeRepr.of[Tuple2])) =>
vppl match
case Nil => VppSet.empty[(String, String)]
case AppliedType(t2, List(vf, vt)) :: tail
if (t2 =:= TypeRepr.of[Tuple2]) =>
val vppset = vpp2str(tail)
vppset.add(
(
Expand All @@ -230,9 +226,9 @@ object ValuePromotion:
vppset
case _ =>
report.error(
s"type ${typestr(vpp)} is not a valid value promotion policy"
s"type ${typestr(vppl.head)} is not a valid promotion pair"
)
VppSet.empty[(String, String)]
null.asInstanceOf[Nothing]

private def pathexists(
vf: String,
Expand All @@ -257,9 +253,10 @@ object ValuePromotion:
done = true
haspath

final class ValuePromotionPolicy[Pairs]
final class ValuePromotionPolicy[Pairs <: Tuple]
object ValuePromotionPolicy:
def apply[P](): ValuePromotionPolicy[P] = new ValuePromotionPolicy[P]
def apply[P <: Tuple](): ValuePromotionPolicy[P] =
new ValuePromotionPolicy[P]

final case class ShowUnit[U](value: String)
object ShowUnit:
Expand Down
Loading