dhall-lang / dhall-to-cabal

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

Spec-version-specific Package types #100

Open quasicomputational opened 6 years ago

quasicomputational commented 6 years ago

From #98:

It turns out that it's easy to generate invalid .cabal files for cabal-version: 2.2, because non-SPDX licenses aren't at all supported, and pre-2.2 spec versions will fail with SPDX. So, if we want to follow the dictum of 'make illegal states unrepresentable', we should change the Package type to be a union of pre-2.2 and post-2.2 records, or do something similar.

There are some other cases where we'd want to do this (e.g., no autogen-modules before whichever version that was introduced in), as well.

quasicomputational commented 6 years ago

An alternative to let Package = < Package2_0 : { ... } | Package2_2 : { ... } | ... > would be to keep Package as it is (a direct translation of PackageDescription) and then implement Package2_0 -> Package and Package2_2 -> Package functions in Dhall, and recommend that this is what users do. That has the advantage that I can try it out today and see if it's horrible or not.