You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
Thank you for creating this project! I'm using toml-scala in new configuration library that I'm working on (adaptation of https://github.com/scalameta/metaconfig) and I'm curious if it would be possible to somehow expose position information in the toml.Value._ case classes.
My goal is to be able to report positioned type error messages when decoding TOML into Scala case classes, for example
# config.tomlbooleanField = "stringValue"
The reported error would look like this
config.toml:0 error: Type mismatch;
found : String
expected : Boolean
booleanField = "stringValue"
^
One way to achieve this with an immutable ADT with minimal boilerplate is to add a private var into the superclass
As long as copyThis().myIndex = is the only place where you mutate the var then the class remains effectively immutable. The position field can be added in a backwards compatible way, it doesn't affect Value equality semantics.
The Rules parser can then construct nodes with the Index fastparse parser and construct nodes with something like this (I didn't check if it compiles)
Another alternative solution would be to add a new visitor API to construct TOML nodes, which the parser would use instead of constructing toml.Value._ nodes directly.
Thank you for creating this project! I'm using toml-scala in new configuration library that I'm working on (adaptation of https://github.com/scalameta/metaconfig) and I'm curious if it would be possible to somehow expose position information in the
toml.Value._
case classes.My goal is to be able to report positioned type error messages when decoding TOML into Scala case classes, for example
The reported error would look like this
One way to achieve this with an immutable ADT with minimal boilerplate is to add a private var into the superclass
As long as
copyThis().myIndex =
is the only place where you mutate the var then the class remains effectively immutable. The position field can be added in a backwards compatible way, it doesn't affectValue
equality semantics.The
Rules
parser can then construct nodes with theIndex
fastparse parser and construct nodes with something like this (I didn't check if it compiles)The text was updated successfully, but these errors were encountered: