dhall-lang / dhall-to-cabal

Compile Dhall expressions to Cabal files
MIT License
100 stars 19 forks source link

cabal-to-dhall: use defaults in output. #83

Closed quasicomputational closed 6 years ago

quasicomputational commented 6 years ago

This implements using defaults to omit boring fields for Package, Executable, Library, Benchmark, TestSuite and CompilerOptions, leading to quite prodigious drops in line-count in the tests and consequent increases in readability.

Closes #57.

ocharles commented 6 years ago

This approach does work, but I wonder if this would be simpler working purely on Dhall Exprs. I can imagine simply turning mempty into an Expr, and the users given Package/Executable and essentially taking the asymmetric difference of users - default and then taking the merge with default /\ user, and finally performing a CSE-like procedure that we do in --print-type to turn default into something that just references the prelude. I'm just worried there is quite a lot of duplication going on with this approach.

quasicomputational commented 6 years ago

Duplication between dhall/defaults/*.dhall and Haskell, you mean? My thinking here is that, with the default values embedded in Haskell, we can generate dhall/defaults/ programmatically and leave the code as the single source of truth.

Hitting it with CSE worries me a bit because we don't have fine control over what will happen; I'd rather be explicit about what and where is going to be defaulted.

ocharles commented 6 years ago

Can you fix the conflicts in this?

quasicomputational commented 6 years ago

Rebased & fixed up!