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

Fix toString's handling of text literals, etc. #7

Closed
travisbrown opened this issue Apr 12, 2020 · 1 comment
Closed

Fix toString's handling of text literals, etc. #7

travisbrown opened this issue Apr 12, 2020 · 1 comment
Labels
bug Something isn't working
Milestone

Comments

@travisbrown
Copy link
Owner

The implementation of toString (taking an expression and writing it back to Dhall code as a string) is currently pretty rough and needs some attention in general, but in particular it doesn't serialize text literals containing newlines correctly. toString hasn't been a high priority for me so far, but the newline issue at least needs to be fixed before the 0.1.0 release.

@travisbrown travisbrown added this to the 0.1.0 milestone Apr 12, 2020
@travisbrown travisbrown added the bug Something isn't working label Apr 12, 2020
@travisbrown
Copy link
Owner Author

This particular issue and some related toString problems are fixed in 02bd091. It's now possible to load the unnormalised Prelude, print it with toString, parse it again, and get the same result:

scala> import org.dhallj.syntax._
import org.dhallj.syntax._

scala> val Right(prelude) = "./dhall-lang/Prelude/package.dhall".parseExpr.flatMap(_.resolve)
prelude: org.dhallj.core.Expr = {`Bool` = ...

scala> val Right(fromToString) = prelude.toString.parseExpr
fromToString: org.dhallj.core.Expr = {`Bool` = ...

scala> prelude.hash
res0: String = ce1b587ca440b150fdc5d892f6a0a54873d0f6ec89a4fcff5b4d698a9ea45189

scala> fromToString.hash
res1: String = ce1b587ca440b150fdc5d892f6a0a54873d0f6ec89a4fcff5b4d698a9ea45189

scala> prelude.diff(fromToString)
res2: Option[(Option[org.dhallj.core.Expr], Option[org.dhallj.core.Expr])] = None

The toString implementation is still a terrible mess, but I think this round of fixes unblocks 0.1.0.

@travisbrown travisbrown changed the title Fix toString's handling of multi-line text literals Fix toString's handling of text literals, etc. Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant