-
Notifications
You must be signed in to change notification settings - Fork 211
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
[POC] Add 'quoted' option #941
[POC] Add 'quoted' option #941
Conversation
Allow to generare quoted scalars if needed via providing a custom encode options to Data.Yaml.encodeWith. So far two corner cases from yaml itself (an empty scalar, and special strings) are omitted in the implementation.
`yaml-0.11.0` split out the `Text.Libyaml` module into a separate `libyaml` Haskell package. However, that means that if you depend on the `libyaml` package then you can no longer use older versions of the `yaml` package because then they will both conflict due to trying to export `Text.LibYaml`. That presents one of two options: * Upgrade `dhall-json` builds for older resolvers to use `yaml-0.11.0` * Downgrade `dhall-json` builds for newer resolvers to use `yaml-0.10.4.0` I went with the latter change since this only affects the `stack.yaml` build and is fairly non-disruptive, whereas upgrading `stack-lts-6.yaml` to use a newer `yaml` was likely to be more disruptive. By pinning to an older version of the `yaml` package we no longer need the `libyaml` dependency in `dhall-json.cabal`, which this change also removes.
CI builds with `-Werror`, so any warnings fail the builds. This change fixes two warnings: * An unused variable warning for the `customStyle` input argument: `s` * A missing type signature for `customStyle` as a top-level function
@erthalion: If you merge erthalion#1 into your branch then I think it will fix the build failures in CI |
Fix build failures in CI
Too simple custom style can break "as Text" import, since it's also going to be quoted. So it needs to be in the condition as Literal.
@erthalion: Hmmm. It looks like you will need to upgrade |
Add the version that supports string rendering styles to stack-lts-12/6
@Gabriel439 Right, it fixes tests for
I'm not sure, is there a better way to fix it, except |
@erthalion: One solution would be to disable the Another solution would be to use CPP to conditionally compile out the You can also try My personal preference is the first solution (discontinue |
Well, really the component needed for etlas is only dhall-haskell, so we could remove dhall-json from lts-6. |
Stupid question, how to do this? I thought it would be enough just to remove |
@erthalion: The Lines 52 to 64 in 2530207
|
530498d
to
afefbb9
Compare
Indeed, @Gabriel439 it worked, thanks for the explanation. I'm going to write a few real tests now. |
To make it testable I've introduced |
3b4e40d
to
641e869
Compare
For the testing purposes yaml generation logic is moved to the library itself. Tests are provided for quoted and normal style, including plain text values.
@erthalion: Yeah, that's totally fine. I usually treat the executable and library dependencies as essentially synonymous. The only dependencies I treat differently are test and benchmark dependencies (since they are not always used). Also, for this package we can be quite liberal with dependencies since it's most commonly use as an executable rather than as a package. |
Excellent job! Thank you for doing this 🙂 |
Thank you! |
You're welcome! |
For #933
Allow to generare quoted scalars if needed via providing a custom encode
options to Data.Yaml.encodeWith. So far two corner cases from yaml
itself (an empty scalar, and special strings) are omitted in the
implementation.