record4s proviedes extensible records for Scala.
See the guide to learn about installation and usage.
record4s is licensed under Apache License, Version 2.0.
Extensible records for Scala
Home Page: https://tarao.orezdnu.org/record4s/
License: Apache License 2.0
record4s proviedes extensible records for Scala.
See the guide to learn about installation and usage.
record4s is licensed under Apache License, Version 2.0.
It seems to me that record4s does not work correctly neither in inline nor transparent inline functions (the difference is important since they are inlined at different times iirc). Probably this is an issue with how the type checking of transparent functions works, so not strictly a bug in this library, but perhaps you can find a better workaround or escalate the issue to the Scala compiler. In any case, I hope that my report will at least serve as documentation for other users.
import com.github.tarao.record4s.%
%(name = "hello") + (bla = 123)
def foo() = {
%(name = "hello") + (bla = 123)
}
inline def bar() = {
%(name = "hello") + (bla = 123)
}
transparent inline def bob() = {
%(name = "hello") + (bla = 123)
}
inline def foobar() = {
(
%(name = "hello").asInstanceOf[% { val name: String }]
+ (bla = 123)
).asInstanceOf[% { val name: String; val bla: Int }]
}
foobar()
Output:
val res0: com.github.tarao.record4s.%{val name: String; val bla: Int} = %(name = hello, bla = 123)
def foo(): com.github.tarao.record4s.%{val name: String; val bla: Int}
-- [E008] Not Found Error: -----------------------------------------------------
2 | %(name = "hello") + (bla = 123)
| ^^^^^^^^^^^^^^^^^^^
|value + is not a member of Any, but could be made available as an extension method.
|
|One of the following imports might make progress towards fixing the problem:
|
| import math.Fractional.Implicits.infixFractionalOps
| import math.Integral.Implicits.infixIntegralOps
| import math.Numeric.Implicits.infixNumericOps
|
1 error found
-- [E008] Not Found Error: -----------------------------------------------------
2 | %(name = "hello") + (bla = 123)
| ^^^^^^^^^^^^^^^^^^^
|value + is not a member of Any, but could be made available as an extension method.
|
|One of the following imports might make progress towards fixing the problem:
|
| import math.Fractional.Implicits.infixFractionalOps
| import math.Integral.Implicits.infixIntegralOps
| import math.Numeric.Implicits.infixNumericOps
|
1 error found
def foobar(): com.github.tarao.record4s.%{val name: String; val bla: Int}
val res1: com.github.tarao.record4s.%{val name: String; val bla: Int} = %(name = hello, bla = 123)
PS: Let me just say that this is an amazing library that doesn't have nearly as many stars as it deserves. It is not only surprisingly usable, but also serves as a good example of whitebox macro techniques ๐
Integration with Jackson would be useful to be able to read and write YAML and TOML via jackson-dataformats-text.
I'll try myself if I have time, but I'm not familiar with any of Scala3/Record4s/Jackson, so I'd be happy to implement it for those who are familiar with them.
(After a little touch and go, it seemed difficult to avoid Type Erasure)
0.12.0
import com.github.tarao.record4s.%
import com.github.tarao.record4s.ArrayRecord
% () == % ()
// res0: Boolean = true
% ().hashCode() == % ().hashCode()
// res1: Boolean = false
ArrayRecord() == ArrayRecord()
// res2: Boolean = true
ArrayRecord().hashCode() == ArrayRecord().hashCode()
// res3: Boolean = false
The general contract of hashCode is:
- Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
- If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
- It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.
Warning
Renovate failed to look up the following dependencies: Failed to look up github-releases package sbt/sbt
.
Files affected: project/build.properties
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
script/python/Dockerfile
.github/workflows/ci.yml
actions/checkout v4
actions/setup-java v4
actions/setup-java v4
actions/setup-java v4
actions/upload-artifact v4
actions/checkout v4
actions/setup-java v4
actions/setup-java v4
actions/setup-java v4
actions/download-artifact v4
actions/download-artifact v4
actions/download-artifact v4
actions/checkout v4
actions/setup-java v4
actions/setup-java v4
actions/setup-java v4
scalacenter/sbt-dependency-submission v2
actions/checkout v4
actions/setup-java v4
coursier/setup-action v1
actions/checkout v4
actions/setup-java v4
actions/checkout v4
actions/setup-java v4
codecov/codecov-action v4
actions/checkout v4
actions/setup-java v4
actions/setup-java v4
actions/setup-java v4
peaceiris/actions-gh-pages v3.9.3
.github/workflows/clean.yml
.github/workflows/scala-steward.yml
scala-steward-org/scala-steward-action v2
ubuntu 22.04
.github/workflows/site.yml
actions/checkout v4
actions/setup-java v4
actions/setup-java v4
actions/setup-java v4
peaceiris/actions-gh-pages v3.9.3
build.sbt
scala 3.3.3
org.scalatest:scalatest 3.2.18
org.getshaka:native-converter 0.9.0
io.circe:circe-core 0.14.6
io.circe:circe-generic 0.14.6
io.circe:circe-parser 0.14.6
com.lihaoyi:upickle 3.2.0
scala 2.13.13
com.chuusai:shapeless 2.3.10
scala 2.11.12
ch.epfl.lamp:scala-records 0.4
io.circe:circe-core 0.14.6
io.circe:circe-generic 0.14.6
io.circe:circe-parser 0.14.6
project/build.properties
sbt/sbt 1.9.9
project/plugins.sbt
pl.project13.scala:sbt-jmh 0.4.7
org.typelevel:sbt-typelevel 0.6.7
org.typelevel:sbt-typelevel-scalafix 0.6.7
org.typelevel:sbt-typelevel-site 0.6.7
org.scala-js:sbt-scalajs 1.15.0
org.scala-native:sbt-scala-native 0.4.17
org.scoverage:sbt-scoverage 2.0.11
Hi,
I have a couple of questions - this would be a discussion rather than an issue... but didn't see discussions on the repo.
ujson
integration?This compiles, but throws at runtime.
import com.github.tarao.record4s.%
import reflect.Selectable.reflectiveSelectable
@main def playdoh =
type BarPlottable = {
val x: Int
val y: Int
val label: String
}
val t = %(x = 1, y = 2, label = "String")
def typeTest(r: BarPlottable) =
println(r.x)
r.y
r.label
typeTest(t)
Compiles, but throws at runtime.
Full disclosure : My interest in your project, is that these sorts of records look dynamic enough to easily constructible from existing data, but static enough to provide the safety guarantees, that would helpful for my pet charting project.
object A {
opaque type Name = String
object Name {
def apply(name: String): Name = name
}
}
import A.Name
val r1 = %(name = Name("tarao"), age = 3)
val r2 = r1 + (email = "[email protected]")
val name: Name = r2.name
-- [E007] Type Mismatch Error: -------------------------------------------------
1 |val name: Name = r2.name
| ^^^^^^^
| Found: String
| Required: A.Name
It should compile.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.