dhall-to-cabal 1.3.2.0 → 1.3.3.0
raw patch · 48 files changed
+775/−1344 lines, 48 filesdep −hashabledep ~dhalldep ~tastyPVP ok
version bump matches the API change (PVP)
Dependencies removed: hashable
Dependency ranges changed: dhall, tasty
API changes (from Hackage documentation)
+ DhallToCabal: executableScope :: Type ExecutableScope
+ DhallToCabal: moduleRenaming :: Type ModuleRenaming
Files
- Changelog.md +18/−0
- README.md +12/−8
- dhall-to-cabal.cabal +10/−80
- dhall/defaults/Benchmark.dhall +1/−1
- dhall/defaults/BuildInfo.dhall +0/−0
- dhall/defaults/CompilerOptions.dhall +25/−23
- dhall/defaults/Executable.dhall +1/−1
- dhall/defaults/Library.dhall +15/−9
- dhall/defaults/Package.dhall +1/−1
- dhall/defaults/SourceRepo.dhall +1/−1
- dhall/defaults/TestSuite.dhall +1/−1
- dhall/types/Arch.dhall +17/−34
- dhall/types/BuildType.dhall +1/−1
- dhall/types/Compiler.dhall +11/−22
- dhall/types/ForeignLibrary.dhall +3/−3
- dhall/types/Language.dhall +1/−1
- dhall/types/License.dhall +13/−22
- dhall/types/ModuleRenaming.dhall +1/−7
- dhall/types/OS.dhall +16/−32
- dhall/types/RepoKind.dhall +1/−1
- dhall/types/RepoType.dhall +8/−16
- dhall/types/SPDX/LicenseExceptionId.dhall +32/−64
- dhall/types/SPDX/LicenseId.dhall +349/−698
- dhall/types/Scope.dhall +1/−1
- dhall/utils/GitHub-project.dhall +1/−1
- exe/Main.hs +35/−17
- golden-tests/cabal-to-dhall/SPDX.dhall +3/−3
- golden-tests/cabal-to-dhall/conditional-dependencies.dhall +4/−4
- golden-tests/cabal-to-dhall/gh-36.dhall +7/−7
- golden-tests/cabal-to-dhall/mixins-no-signatures.dhall +4/−4
- golden-tests/cabal-to-dhall/sourcerepo-defaults.dhall +3/−7
- golden-tests/cabal-to-dhall/unknown-license.cabal +4/−0
- golden-tests/cabal-to-dhall/unknown-license.dhall +14/−0
- golden-tests/dhall-to-cabal/SPDX.dhall +3/−3
- golden-tests/dhall-to-cabal/allrightsreserved-2.0.dhall +1/−1
- golden-tests/dhall-to-cabal/allrightsreserved-2.2.dhall +1/−1
- golden-tests/dhall-to-cabal/compiler-options-order.dhall +1/−1
- golden-tests/dhall-to-cabal/conditional-dependencies.dhall +1/−1
- golden-tests/dhall-to-cabal/dhall-to-cabal.dhall +5/−5
- golden-tests/dhall-to-cabal/gh-53.dhall +1/−1
- golden-tests/dhall-to-cabal/gh-55.dhall +1/−1
- golden-tests/dhall-to-cabal/map-source-repo.dhall +1/−1
- golden-tests/dhall-to-cabal/mixins-no-signatures.dhall +4/−4
- golden-tests/dhall-to-cabal/nested-conditions.dhall +2/−2
- lib/CabalToDhall.hs +67/−124
- lib/Dhall/Extra.hs +1/−22
- lib/DhallLocation.hs +0/−2
- lib/DhallToCabal.hs +72/−105
Changelog.md view
@@ -1,5 +1,23 @@ # dhall-to-cabal change log +## 1.3.3.0 -- 2019-05-15++* All constructors that previously took an empty record now use the+ new nullary syntax instead. This is a breaking change for user code.+ For example, instead of `types.Compiler.GHC {=}`, now you just write+ `types.Compiler.GHC`.++* Use `dhall` version 1.23.0.++* Educated `--print-type` about `Scope` and `ModuleRenaming`.++* Fix `cabal-to-dhall` output for unknown licenses using `cabal` spec+ version below `2.0`. Now it uses values of type `License.Unknown Text` + for them.++* Improved `--print-type` and `--print-default` output to use+ multi-binding `let`.+ ## 1.3.2.0 -- 2019-02-12 * Use `dhall` version 1.20.1.
README.md view
@@ -30,17 +30,21 @@ `dhall-to-cabal --print-type`. (In the future, we will have more human-ready documentation - we'd love your help here!) -Once you have your Dhall file ready, run it through `dhall-to-cabal` and-redirect the output to a Cabal file:+Once you have your Dhall file ready, point `dhall-to-cabal` at it: ``` shell-dhall-to-cabal input.dhall > output.cabal+dhall-to-cabal input.dhall ``` -(Replace the names `input.dhall` and `output.dhall`).+(Replace the name `input.dhall` with your actual input file). -That's it!+That's it! `dhall-to-cabal` does the rest - it will figure out what+the `.cabal` file should be called, and write it out next to the+input. +If you'd rather put the file somewhere else, have a look at+`dhall-to-cabal --help` and use one of the `--output-*` options.+ ### cabal-to-dhall Good news! `dhall-to-cabal` is currently running a two-for-one deal! By@@ -75,7 +79,7 @@ To give you an example of a Dhall expression, let's jump straight in and see an example of a Dhall expression that can be used with `dhall-to-cabal`: -```+```haskell let GitHub-project = https://raw.githubusercontent.com/ocharles/dhall-to-cabal/1.0.0/dhall/GitHub-project.dhall @@ -140,7 +144,7 @@ A small example Cabal file is -```+```cabal name: example cabal-version: 2.0 build-type: Simple@@ -244,7 +248,7 @@ Haskell *web applications* look like? Does the separate of `library`, `executable`, and `test-suite` make sense here? Maybe we'd rather: - ```+ ```haskell servant-project { api-route = "My.API.Route" server = "My.API.Server"
dhall-to-cabal.cabal view
@@ -9,7 +9,7 @@ -- 'dhall-to-cabal -- dhall-to-cabal.dhall'. -- * * * * * * * * * * * * WARNING * * * * * * * * * * * * name: dhall-to-cabal-version: 1.3.2.0+version: 1.3.3.0 license: MIT license-file: LICENSE maintainer: ollie@ocharles.org.uk@@ -28,76 +28,7 @@ extra-source-files: Changelog.md README.md- dhall/SPDX/and.dhall- dhall/SPDX/license.dhall- dhall/SPDX/licenseVersionOrLater.dhall- dhall/SPDX/or.dhall- dhall/SPDX/ref.dhall- dhall/SPDX/refWithFile.dhall- dhall/Version/v.dhall- dhall/VersionRange/anyVersion.dhall- dhall/VersionRange/differenceVersionRanges.dhall- dhall/VersionRange/earlierVersion.dhall- dhall/VersionRange/intersectVersionRanges.dhall- dhall/VersionRange/invertVersionRange.dhall- dhall/VersionRange/laterVersion.dhall- dhall/VersionRange/majorBoundVersion.dhall- dhall/VersionRange/noVersion.dhall- dhall/VersionRange/notThisVersion.dhall- dhall/VersionRange/orEarlierVersion.dhall- dhall/VersionRange/orLaterVersion.dhall- dhall/VersionRange/thisVersion.dhall- dhall/VersionRange/unionVersionRanges.dhall- dhall/VersionRange/withinVersion.dhall- dhall/defaults/Benchmark.dhall- dhall/defaults/BuildInfo.dhall- dhall/defaults/CompilerOptions.dhall- dhall/defaults/Executable.dhall- dhall/defaults/Library.dhall- dhall/defaults/Package.dhall- dhall/defaults/SourceRepo.dhall- dhall/defaults/TestSuite.dhall- dhall/prelude.dhall- dhall/types.dhall- dhall/types/Arch.dhall- dhall/types/Benchmark.dhall- dhall/types/BuildInfo.dhall- dhall/types/BuildType.dhall- dhall/types/Compiler.dhall- dhall/types/CompilerOptions.dhall- dhall/types/Config.dhall- dhall/types/CustomSetup.dhall- dhall/types/Dependency.dhall- dhall/types/Executable.dhall- dhall/types/Extension.dhall- dhall/types/Flag.dhall- dhall/types/ForeignLibrary.dhall- dhall/types/Guarded.dhall- dhall/types/Language.dhall- dhall/types/Library.dhall- dhall/types/License.dhall- dhall/types/Mixin.dhall- dhall/types/ModuleRenaming.dhall- dhall/types/OS.dhall- dhall/types/Package.dhall- dhall/types/RepoKind.dhall- dhall/types/RepoType.dhall- dhall/types/SPDX.dhall- dhall/types/SPDX/LicenseExceptionId.dhall- dhall/types/SPDX/LicenseId.dhall- dhall/types/Scope.dhall- dhall/types/SetupBuildInfo.dhall- dhall/types/SourceRepo.dhall- dhall/types/TestSuite.dhall- dhall/types/TestType.dhall- dhall/types/Version.dhall- dhall/types/VersionRange.dhall- dhall/types/builtin.dhall- dhall/unconditional.dhall- dhall/utils/GitHub-project.dhall- dhall/utils/majorVersions.dhall- dhall/utils/mapSourceRepos.dhall- dhall/utils/package.dhall+ dhall/**/*.dhall golden-tests/dhall-to-cabal/*.dhall golden-tests/dhall-to-cabal/*.cabal golden-tests/cabal-to-dhall/*.dhall@@ -135,9 +66,8 @@ bytestring ^>=0.10, containers ^>=0.5 || ^>=0.6, contravariant ^>=1.4 || ^>=1.5,- dhall ^>=1.20.1,+ dhall ^>=1.23.0, filepath ^>=1.4,- hashable ^>=1.2.6.1, text ^>=1.2, transformers ^>=0.5.2, vector ^>=0.12@@ -159,7 +89,7 @@ build-depends: Cabal ^>=2.4, base ^>=4.10 || ^>=4.11 || ^>=4.12,- dhall ^>=1.20.1,+ dhall ^>=1.23.0, dhall-to-cabal -any, directory ^>=1.3.0.2, filepath ^>=1.4,@@ -185,7 +115,7 @@ -fno-warn-name-shadowing build-depends: base ^>=4.10 || ^>=4.11 || ^>=4.12,- dhall ^>=1.20.1,+ dhall ^>=1.23.0, bytestring ^>=0.10, dhall-to-cabal -any, optparse-applicative ^>=0.13.2 || ^>=0.14,@@ -205,7 +135,7 @@ build-depends: base ^>=4.10 || ^>=4.11 || ^>=4.12, directory ^>=1.3.0.2,- dhall ^>=1.20.1,+ dhall ^>=1.23.0, dhall-to-cabal -any, filepath ^>=1.4, optparse-applicative ^>=0.13.2 || ^>=0.14,@@ -226,12 +156,12 @@ Cabal ^>=2.4, Diff ^>=0.3.4, bytestring ^>=0.10,- dhall ^>=1.20.1,+ dhall ^>=1.23.0, dhall-to-cabal -any, filepath ^>=1.4, microlens ^>=0.1.0.0 || ^>=0.2.0.0 || ^>=0.3.0.0 || ^>=0.4.0.0, prettyprinter ^>=1.2.0.1,- tasty ^>=0.11 || ^>=0.12 || ^>=1.0 || ^>=1.1,+ tasty ^>=0.11 || ^>=0.12 || ^>=1.0 || ^>=1.1 || ^>=1.2, tasty-golden ^>=2.3, text ^>=1.2 @@ -250,8 +180,8 @@ build-depends: base ^>=4.10 || ^>=4.11 || ^>=4.12, Cabal ^>=2.4,- dhall ^>=1.20.1,+ dhall ^>=1.23.0, dhall-to-cabal -any,- tasty ^>=0.11 || ^>=0.12 || ^>=1.0 || ^>=1.1,+ tasty ^>=0.11 || ^>=0.12 || ^>=1.0 || ^>=1.1 || ^>=1.2, tasty-hunit ^>=0.10.0.1, text ^>=1.2
dhall/defaults/Benchmark.dhall view
@@ -1,2 +1,2 @@ -- This file is auto-generated by dhall-to-cabal-meta. Look but don't touch (unless you want your edits to be over-written).-././BuildInfo.dhall+let types = ./../types.dhall in ././BuildInfo.dhall
dhall/defaults/BuildInfo.dhall view
dhall/defaults/CompilerOptions.dhall view
@@ -1,24 +1,26 @@ -- This file is auto-generated by dhall-to-cabal-meta. Look but don't touch (unless you want your edits to be over-written).-{ Eta =- [] : List Text-, GHC =- [] : List Text-, GHCJS =- [] : List Text-, HBC =- [] : List Text-, Helium =- [] : List Text-, Hugs =- [] : List Text-, JHC =- [] : List Text-, LHC =- [] : List Text-, NHC =- [] : List Text-, UHC =- [] : List Text-, YHC =- [] : List Text-}+let types = ./../types.dhall++in { Eta =+ [] : List Text+ , GHC =+ [] : List Text+ , GHCJS =+ [] : List Text+ , HBC =+ [] : List Text+ , Helium =+ [] : List Text+ , Hugs =+ [] : List Text+ , JHC =+ [] : List Text+ , LHC =+ [] : List Text+ , NHC =+ [] : List Text+ , UHC =+ [] : List Text+ , YHC =+ [] : List Text+ }
dhall/defaults/Executable.dhall view
@@ -1,4 +1,4 @@ -- This file is auto-generated by dhall-to-cabal-meta. Look but don't touch (unless you want your edits to be over-written). let types = ./../types.dhall -in ././BuildInfo.dhall ⫽ { scope = types.Scope.Public {=} }+in ././BuildInfo.dhall ⫽ { scope = types.Scope.Public }
dhall/defaults/Library.dhall view
@@ -1,10 +1,16 @@ -- This file is auto-generated by dhall-to-cabal-meta. Look but don't touch (unless you want your edits to be over-written).- ././BuildInfo.dhall-⫽ { exposed-modules =- [] : List Text- , reexported-modules =- [] : List- { name : Text, original : { name : Text, package : Optional Text } }- , signatures =- [] : List Text- }+let types = ./../types.dhall++in ././BuildInfo.dhall+ ⫽ { exposed-modules =+ [] : List Text+ , reexported-modules =+ [] : List+ { name :+ Text+ , original :+ { name : Text, package : Optional Text }+ }+ , signatures =+ [] : List Text+ }
dhall/defaults/Package.dhall view
@@ -54,7 +54,7 @@ , library = None (∀(config : types.Config) → types.Library) , license =- types.License.AllRightsReserved {=}+ types.License.AllRightsReserved , license-files = [] : List Text , maintainer =
dhall/defaults/SourceRepo.dhall view
@@ -14,5 +14,5 @@ , subdir = None Text , kind =- types.RepoKind.RepoHead {=}+ types.RepoKind.RepoHead }
dhall/defaults/TestSuite.dhall view
@@ -1,2 +1,2 @@ -- This file is auto-generated by dhall-to-cabal-meta. Look but don't touch (unless you want your edits to be over-written).-././BuildInfo.dhall+let types = ./../types.dhall in ././BuildInfo.dhall
dhall/types/Arch.dhall view
@@ -1,37 +1,20 @@-< AArch64 :- {}-| Alpha :- {}-| Arm :- {}-| Hppa :- {}-| I386 :- {}-| IA64 :- {}-| JavaScript :- {}-| M68k :- {}-| Mips :- {}+< AArch64+| Alpha+| Arm+| Hppa+| I386+| IA64+| JavaScript+| M68k+| Mips | OtherArch : { _1 : Text }-| PPC :- {}-| PPC64 :- {}-| Rs6000 :- {}-| S390 :- {}-| SH :- {}-| Sparc :- {}-| Vax :- {}-| X86_64 :- {}+| PPC+| PPC64+| Rs6000+| S390+| SH+| Sparc+| Vax+| X86_64 >
dhall/types/BuildType.dhall view
@@ -1,1 +1,1 @@-< Configure : {} | Custom : {} | Make : {} | Simple : {} >+< Configure | Custom | Make | Simple >
dhall/types/Compiler.dhall view
@@ -1,27 +1,16 @@-< Eta :- {}-| GHC :- {}-| GHCJS :- {}-| HBC :- {}+< Eta+| GHC+| GHCJS+| HBC | HaskellSuite : { _1 : Text }-| Helium :- {}-| Hugs :- {}-| JHC :- {}-| LHC :- {}-| NHC :- {}+| Helium+| Hugs+| JHC+| LHC+| NHC | OtherCompiler : { _1 : Text }-| UHC :- {}-| YHC :- {}+| UHC+| YHC >
dhall/types/ForeignLibrary.dhall view
@@ -1,10 +1,10 @@ ./BuildInfo.dhall ⩓ { type :- < Shared : {} | Static : {} >+ < Shared | Static > , options :- List < Standalone : {} >+ List < Standalone > , lib-version-info :- Optional { age : Natural, current : Natural, revision : Natural }+ Optional { current : Natural, revision : Natural, age : Natural } , lib-version-linux : Optional ./Version.dhall , mod-def-files :
dhall/types/Language.dhall view
@@ -1,1 +1,1 @@-< Haskell2010 : {} | Haskell98 : {} | UnknownLanguage : { _1 : Text } >+< Haskell2010 | Haskell98 | UnknownLanguage : { _1 : Text } >
dhall/types/License.dhall view
@@ -1,33 +1,24 @@-< AGPL :- Optional ./Version.dhall-| AllRightsReserved :- {}-| Apache :+< GPL : Optional ./Version.dhall-| BSD2 :- {}-| BSD3 :- {}-| BSD4 :- {}-| GPL :+| AGPL : Optional ./Version.dhall-| ISC :- {} | LGPL : Optional ./Version.dhall-| MIT :- {}+| BSD2+| BSD3+| BSD4+| MIT+| ISC | MPL : ./Version.dhall-| Other :- {}-| PublicDomain :- {}-| Unspecified :- {}+| Apache :+ Optional ./Version.dhall+| PublicDomain+| AllRightsReserved+| Unspecified | Unknown : Text+| Other | SPDX : ./SPDX.dhall >
dhall/types/ModuleRenaming.dhall view
@@ -1,7 +1,1 @@-< renaming :- List { rename : Text, to : Text }-| default :- {}-| hiding :- List Text->+< renaming : List { rename : Text, to : Text } | default | hiding : List Text >
dhall/types/OS.dhall view
@@ -1,35 +1,19 @@-< AIX :- {}-| Android :- {}-| DragonFly :- {}-| FreeBSD :- {}-| Ghcjs :- {}-| HPUX :- {}-| HaLVM :- {}-| Hurd :- {}-| IOS :- {}-| IRIX :- {}-| Linux :- {}-| NetBSD :- {}-| OSX :- {}-| OpenBSD :- {}+< AIX+| Android+| DragonFly+| FreeBSD+| Ghcjs+| HPUX+| HaLVM+| Hurd+| IOS+| IRIX+| Linux+| NetBSD+| OSX+| OpenBSD | OtherOS : { _1 : Text }-| Solaris :- {}-| Windows :- {}+| Solaris+| Windows >
dhall/types/RepoKind.dhall view
@@ -1,1 +1,1 @@-< RepoHead : {} | RepoKindUnknown : { _1 : Text } | RepoThis : {} >+< RepoHead | RepoKindUnknown : { _1 : Text } | RepoThis >
dhall/types/RepoType.dhall view
@@ -1,19 +1,11 @@-< Bazaar :- {}-| CVS :- {}-| Darcs :- {}-| Git :- {}-| GnuArch :- {}-| Mercurial :- {}-| Monotone :- {}+< Bazaar+| CVS+| Darcs+| Git+| GnuArch+| Mercurial+| Monotone | OtherRepoType : { _1 : Text }-| SVN :- {}+| SVN >
dhall/types/SPDX/LicenseExceptionId.dhall view
@@ -1,65 +1,33 @@-< DS389_exception :- {}-| Autoconf_exception_2_0 :- {}-| Autoconf_exception_3_0 :- {}-| Bison_exception_2_2 :- {}-| Bootloader_exception :- {}-| Classpath_exception_2_0 :- {}-| CLISP_exception_2_0 :- {}-| DigiRule_FOSS_exception :- {}-| ECos_exception_2_0 :- {}-| Fawkes_Runtime_exception :- {}-| FLTK_exception :- {}-| Font_exception_2_0 :- {}-| Freertos_exception_2_0 :- {}-| GCC_exception_2_0 :- {}-| GCC_exception_3_1 :- {}-| Gnu_javamail_exception :- {}-| I2p_gpl_java_exception :- {}-| Libtool_exception :- {}-| Linux_syscall_note :- {}-| LLVM_exception :- {}-| LZMA_exception :- {}-| Mif_exception :- {}-| Nokia_Qt_exception_1_1 :- {}-| OCCT_exception_1_0 :- {}-| OpenJDK_assembly_exception_1_0 :- {}-| Openvpn_openssl_exception :- {}-| PS_or_PDF_font_exception_20170817 :- {}-| Qt_GPL_exception_1_0 :- {}-| Qt_LGPL_exception_1_1 :- {}-| Qwt_exception_1_0 :- {}-| U_boot_exception_2_0 :- {}-| WxWindows_exception_3_1 :- {}+< DS389_exception+| Autoconf_exception_2_0+| Autoconf_exception_3_0+| Bison_exception_2_2+| Bootloader_exception+| Classpath_exception_2_0+| CLISP_exception_2_0+| DigiRule_FOSS_exception+| ECos_exception_2_0+| Fawkes_Runtime_exception+| FLTK_exception+| Font_exception_2_0+| Freertos_exception_2_0+| GCC_exception_2_0+| GCC_exception_3_1+| Gnu_javamail_exception+| I2p_gpl_java_exception+| Libtool_exception+| Linux_syscall_note+| LLVM_exception+| LZMA_exception+| Mif_exception+| Nokia_Qt_exception_1_1+| OCCT_exception_1_0+| OpenJDK_assembly_exception_1_0+| Openvpn_openssl_exception+| PS_or_PDF_font_exception_20170817+| Qt_GPL_exception_1_0+| Qt_LGPL_exception_1_1+| Qwt_exception_1_0+| U_boot_exception_2_0+| WxWindows_exception_3_1 >
dhall/types/SPDX/LicenseId.dhall view
@@ -1,699 +1,350 @@-< NullBSD :- {}-| AAL :- {}-| Adobe_2006 :- {}-| Adobe_Glyph :- {}-| Abstyles :- {}-| ADSL :- {}-| AFL_1_1 :- {}-| AFL_2_0 :- {}-| AFL_2_1 :- {}-| AFL_1_2 :- {}-| AFL_3_0 :- {}-| Afmparse :- {}-| AGPL_1_0_only :- {}-| AGPL_1_0_or_later :- {}-| AGPL_1_0 :- {}-| AGPL_3_0_or_later :- {}-| Aladdin :- {}-| AGPL_3_0_only :- {}-| AML :- {}-| AMPAS :- {}-| AMDPLPA :- {}-| ANTLR_PD :- {}-| Apache_1_0 :- {}-| Apache_2_0 :- {}-| APAFML :- {}-| Apache_1_1 :- {}-| APSL_1_0 :- {}-| APSL_1_1 :- {}-| APL_1_0 :- {}-| APSL_2_0 :- {}-| Artistic_1_0_cl8 :- {}-| APSL_1_2 :- {}-| Artistic_1_0_Perl :- {}-| Artistic_1_0 :- {}-| Bahyph :- {}-| Barr :- {}-| Artistic_2_0 :- {}-| BitTorrent_1_0 :- {}-| BitTorrent_1_1 :- {}-| Beerware :- {}-| BSD_1_Clause :- {}-| BSD_2_Clause_FreeBSD :- {}-| Borceux :- {}-| BSD_2_Clause_NetBSD :- {}-| BSD_2_Clause_Patent :- {}-| BSD_3_Clause_Attribution :- {}-| BSD_3_Clause_Clear :- {}-| BSD_2_Clause :- {}-| BSD_3_Clause_No_Nuclear_License_2014 :- {}-| BSD_3_Clause_No_Nuclear_License :- {}-| BSD_3_Clause_LBNL :- {}-| BSD_3_Clause :- {}-| BSD_4_Clause_UC :- {}-| BSD_3_Clause_No_Nuclear_Warranty :- {}-| BSD_4_Clause :- {}-| BSD_Protection :- {}-| BSL_1_0 :- {}-| Bzip2_1_0_5 :- {}-| BSD_Source_Code :- {}-| Caldera :- {}-| CATOSL_1_1 :- {}-| Bzip2_1_0_6 :- {}-| CC_BY_2_0 :- {}-| CC_BY_2_5 :- {}-| CC_BY_1_0 :- {}-| CC_BY_3_0 :- {}-| CC_BY_4_0 :- {}-| CC_BY_NC_2_0 :- {}-| CC_BY_NC_2_5 :- {}-| CC_BY_NC_1_0 :- {}-| CC_BY_NC_4_0 :- {}-| CC_BY_NC_ND_1_0 :- {}-| CC_BY_NC_3_0 :- {}-| CC_BY_NC_ND_2_5 :- {}-| CC_BY_NC_ND_3_0 :- {}-| CC_BY_NC_ND_2_0 :- {}-| CC_BY_NC_ND_4_0 :- {}-| CC_BY_NC_SA_1_0 :- {}-| CC_BY_NC_SA_2_5 :- {}-| CC_BY_NC_SA_3_0 :- {}-| CC_BY_NC_SA_2_0 :- {}-| CC_BY_ND_1_0 :- {}-| CC_BY_ND_2_0 :- {}-| CC_BY_NC_SA_4_0 :- {}-| CC_BY_ND_3_0 :- {}-| CC_BY_ND_4_0 :- {}-| CC_BY_ND_2_5 :- {}-| CC_BY_SA_1_0 :- {}-| CC_BY_SA_2_0 :- {}-| CC_BY_SA_3_0 :- {}-| CC_BY_SA_4_0 :- {}-| CC_BY_SA_2_5 :- {}-| CC0_1_0 :- {}-| CDDL_1_0 :- {}-| CDLA_Permissive_1_0 :- {}-| CDLA_Sharing_1_0 :- {}-| CDDL_1_1 :- {}-| CECILL_1_0 :- {}-| CECILL_1_1 :- {}-| CECILL_2_1 :- {}-| CECILL_B :- {}-| CECILL_2_0 :- {}-| ClArtistic :- {}-| CNRI_Jython :- {}-| CECILL_C :- {}-| CNRI_Python :- {}-| Condor_1_1 :- {}-| CNRI_Python_GPL_Compatible :- {}-| CPAL_1_0 :- {}-| CPL_1_0 :- {}-| Crossword :- {}-| CrystalStacker :- {}-| CPOL_1_02 :- {}-| Cube :- {}-| Curl :- {}-| CUA_OPL_1_0 :- {}-| Diffmark :- {}-| DOC :- {}-| D_FSL_1_0 :- {}-| Dotseqn :- {}-| DSDP :- {}-| ECL_1_0 :- {}-| ECL_2_0 :- {}-| Dvipdfm :- {}-| EFL_2_0 :- {}-| EGenix :- {}-| EFL_1_0 :- {}-| EPL_1_0 :- {}-| EPL_2_0 :- {}-| Entessa :- {}-| ErlPL_1_1 :- {}-| EUDatagrid :- {}-| EUPL_1_1 :- {}-| EUPL_1_2 :- {}-| EUPL_1_0 :- {}-| Fair :- {}-| Frameworx_1_0 :- {}-| Eurosym :- {}-| FSFAP :- {}-| FSFUL :- {}-| FreeImage :- {}-| FSFULLR :- {}-| FTL :- {}-| GFDL_1_1_or_later :- {}-| GFDL_1_2_only :- {}-| GFDL_1_1_only :- {}-| GFDL_1_3_only :- {}-| GFDL_1_3_or_later :- {}-| GFDL_1_2_or_later :- {}-| GL2PS :- {}-| Glide :- {}-| Giftware :- {}-| Glulxe :- {}-| Gnuplot :- {}-| GPL_1_0_or_later :- {}-| GPL_2_0_only :- {}-| GPL_1_0_only :- {}-| GPL_3_0_only :- {}-| GPL_3_0_or_later :- {}-| GPL_2_0_or_later :- {}-| HaskellReport :- {}-| HPND :- {}-| GSOAP_1_3b :- {}-| IBM_pibs :- {}-| ICU :- {}-| ImageMagick :- {}-| IMatix :- {}-| IJG :- {}-| Info_ZIP :- {}-| Intel_ACPI :- {}-| Imlib2 :- {}-| Interbase_1_0 :- {}-| IPA :- {}-| Intel :- {}-| IPL_1_0 :- {}-| ISC :- {}-| JSON :- {}-| LAL_1_2 :- {}-| JasPer_2_0 :- {}-| LAL_1_3 :- {}-| Latex2e :- {}-| LGPL_2_0_only :- {}-| LGPL_2_0_or_later :- {}-| Leptonica :- {}-| LGPL_2_1_only :- {}-| LGPL_2_1_or_later :- {}-| LGPL_3_0_or_later :- {}-| LGPLLR :- {}-| LGPL_3_0_only :- {}-| Libtiff :- {}-| LiLiQ_P_1_1 :- {}-| Libpng :- {}-| LiLiQ_Rplus_1_1 :- {}-| Linux_OpenIB :- {}-| LiLiQ_R_1_1 :- {}-| LPL_1_0 :- {}-| LPL_1_02 :- {}-| LPPL_1_1 :- {}-| LPPL_1_2 :- {}-| LPPL_1_0 :- {}-| LPPL_1_3c :- {}-| MakeIndex :- {}-| LPPL_1_3a :- {}-| MIT_0 :- {}-| MIT_advertising :- {}-| MirOS :- {}-| MIT_CMU :- {}-| MIT_enna :- {}-| MIT :- {}-| MITNFA :- {}-| MIT_feh :- {}-| Mpich2 :- {}-| MPL_1_0 :- {}-| Motosoto :- {}-| MPL_2_0_no_copyleft_exception :- {}-| MPL_2_0 :- {}-| MPL_1_1 :- {}-| MS_PL :- {}-| MS_RL :- {}-| Multics :- {}-| Mup :- {}-| MTLL :- {}-| Naumen :- {}-| NBPL_1_0 :- {}-| NASA_1_3 :- {}-| Net_SNMP :- {}-| NetCDF :- {}-| NCSA :- {}-| Newsletr :- {}-| NGPL :- {}-| NLPL :- {}-| Nokia :- {}-| NLOD_1_0 :- {}-| Noweb :- {}-| NPL_1_0 :- {}-| NOSL :- {}-| NPOSL_3_0 :- {}-| NRL :- {}-| NPL_1_1 :- {}-| NTP :- {}-| OCCT_PL :- {}-| ODbL_1_0 :- {}-| ODC_By_1_0 :- {}-| OCLC_2_0 :- {}-| OFL_1_1 :- {}-| OGTSL :- {}-| OFL_1_0 :- {}-| OLDAP_1_2 :- {}-| OLDAP_1_3 :- {}-| OLDAP_1_1 :- {}-| OLDAP_1_4 :- {}-| OLDAP_2_0_1 :- {}-| OLDAP_2_1 :- {}-| OLDAP_2_2_1 :- {}-| OLDAP_2_0 :- {}-| OLDAP_2_2 :- {}-| OLDAP_2_3 :- {}-| OLDAP_2_2_2 :- {}-| OLDAP_2_5 :- {}-| OLDAP_2_6 :- {}-| OLDAP_2_4 :- {}-| OLDAP_2_7 :- {}-| OLDAP_2_8 :- {}-| OpenSSL :- {}-| OPL_1_0 :- {}-| OML :- {}-| OSL_1_0 :- {}-| OSL_1_1 :- {}-| OSET_PL_2_1 :- {}-| OSL_2_1 :- {}-| OSL_3_0 :- {}-| OSL_2_0 :- {}-| PDDL_1_0 :- {}-| PHP_3_0 :- {}-| Plexus :- {}-| PostgreSQL :- {}-| PHP_3_01 :- {}-| Psutils :- {}-| Python_2_0 :- {}-| Psfrag :- {}-| QPL_1_0 :- {}-| Rdisc :- {}-| Qhull :- {}-| RHeCos_1_1 :- {}-| RPL_1_1 :- {}-| RPSL_1_0 :- {}-| RSA_MD :- {}-| RPL_1_5 :- {}-| Ruby :- {}-| SAX_PD :- {}-| RSCPL :- {}-| SCEA :- {}-| Sendmail :- {}-| Saxpath :- {}-| SGI_B_1_0 :- {}-| SGI_B_1_1 :- {}-| SimPL_2_0 :- {}-| SISSL_1_2 :- {}-| SGI_B_2_0 :- {}-| Sleepycat :- {}-| SMLNJ :- {}-| SISSL :- {}-| SNIA :- {}-| Spencer_86 :- {}-| SMPPL :- {}-| Spencer_94 :- {}-| Spencer_99 :- {}-| SugarCRM_1_1_3 :- {}-| SWL :- {}-| SPL_1_0 :- {}-| TCP_wrappers :- {}-| TMate :- {}-| TCL :- {}-| TOSL :- {}-| TU_Berlin_1_0 :- {}-| TORQUE_1_1 :- {}-| TU_Berlin_2_0 :- {}-| Unicode_DFS_2015 :- {}-| Unicode_TOU :- {}-| Unlicense :- {}-| Unicode_DFS_2016 :- {}-| Vim :- {}-| VOSTROM :- {}-| UPL_1_0 :- {}-| W3C_19980720 :- {}-| W3C_20150513 :- {}-| VSL_1_0 :- {}-| W3C :- {}-| Watcom_1_0 :- {}-| WTFPL :- {}-| X11 :- {}-| Wsuipa :- {}-| XFree86_1_1 :- {}-| Xinetd :- {}-| Xerox :- {}-| Xpp :- {}-| XSkat :- {}-| Xnet :- {}-| YPL_1_0 :- {}-| YPL_1_1 :- {}-| Zend_2_0 :- {}-| Zimbra_1_3 :- {}-| Zed :- {}-| Zlib_acknowledgement :- {}-| Zlib :- {}-| Zimbra_1_4 :- {}-| ZPL_2_0 :- {}-| ZPL_2_1 :- {}-| ZPL_1_1 :- {}+< NullBSD+| AAL+| Abstyles+| Adobe_2006+| Adobe_Glyph+| ADSL+| AFL_1_1+| AFL_1_2+| AFL_2_0+| AFL_2_1+| AFL_3_0+| Afmparse+| AGPL_1_0+| AGPL_1_0_only+| AGPL_1_0_or_later+| AGPL_3_0_only+| AGPL_3_0_or_later+| Aladdin+| AMDPLPA+| AML+| AMPAS+| ANTLR_PD+| Apache_1_0+| Apache_1_1+| Apache_2_0+| APAFML+| APL_1_0+| APSL_1_0+| APSL_1_1+| APSL_1_2+| APSL_2_0+| Artistic_1_0_cl8+| Artistic_1_0_Perl+| Artistic_1_0+| Artistic_2_0+| Bahyph+| Barr+| Beerware+| BitTorrent_1_0+| BitTorrent_1_1+| Borceux+| BSD_1_Clause+| BSD_2_Clause_FreeBSD+| BSD_2_Clause_NetBSD+| BSD_2_Clause_Patent+| BSD_2_Clause+| BSD_3_Clause_Attribution+| BSD_3_Clause_Clear+| BSD_3_Clause_LBNL+| BSD_3_Clause_No_Nuclear_License_2014+| BSD_3_Clause_No_Nuclear_License+| BSD_3_Clause_No_Nuclear_Warranty+| BSD_3_Clause+| BSD_4_Clause_UC+| BSD_4_Clause+| BSD_Protection+| BSD_Source_Code+| BSL_1_0+| Bzip2_1_0_5+| Bzip2_1_0_6+| Caldera+| CATOSL_1_1+| CC_BY_1_0+| CC_BY_2_0+| CC_BY_2_5+| CC_BY_3_0+| CC_BY_4_0+| CC_BY_NC_1_0+| CC_BY_NC_2_0+| CC_BY_NC_2_5+| CC_BY_NC_3_0+| CC_BY_NC_4_0+| CC_BY_NC_ND_1_0+| CC_BY_NC_ND_2_0+| CC_BY_NC_ND_2_5+| CC_BY_NC_ND_3_0+| CC_BY_NC_ND_4_0+| CC_BY_NC_SA_1_0+| CC_BY_NC_SA_2_0+| CC_BY_NC_SA_2_5+| CC_BY_NC_SA_3_0+| CC_BY_NC_SA_4_0+| CC_BY_ND_1_0+| CC_BY_ND_2_0+| CC_BY_ND_2_5+| CC_BY_ND_3_0+| CC_BY_ND_4_0+| CC_BY_SA_1_0+| CC_BY_SA_2_0+| CC_BY_SA_2_5+| CC_BY_SA_3_0+| CC_BY_SA_4_0+| CC0_1_0+| CDDL_1_0+| CDDL_1_1+| CDLA_Permissive_1_0+| CDLA_Sharing_1_0+| CECILL_1_0+| CECILL_1_1+| CECILL_2_0+| CECILL_2_1+| CECILL_B+| CECILL_C+| ClArtistic+| CNRI_Jython+| CNRI_Python_GPL_Compatible+| CNRI_Python+| Condor_1_1+| CPAL_1_0+| CPL_1_0+| CPOL_1_02+| Crossword+| CrystalStacker+| CUA_OPL_1_0+| Cube+| Curl+| D_FSL_1_0+| Diffmark+| DOC+| Dotseqn+| DSDP+| Dvipdfm+| ECL_1_0+| ECL_2_0+| EFL_1_0+| EFL_2_0+| EGenix+| Entessa+| EPL_1_0+| EPL_2_0+| ErlPL_1_1+| EUDatagrid+| EUPL_1_0+| EUPL_1_1+| EUPL_1_2+| Eurosym+| Fair+| Frameworx_1_0+| FreeImage+| FSFAP+| FSFUL+| FSFULLR+| FTL+| GFDL_1_1_only+| GFDL_1_1_or_later+| GFDL_1_2_only+| GFDL_1_2_or_later+| GFDL_1_3_only+| GFDL_1_3_or_later+| Giftware+| GL2PS+| Glide+| Glulxe+| Gnuplot+| GPL_1_0_only+| GPL_1_0_or_later+| GPL_2_0_only+| GPL_2_0_or_later+| GPL_3_0_only+| GPL_3_0_or_later+| GSOAP_1_3b+| HaskellReport+| HPND+| IBM_pibs+| ICU+| IJG+| ImageMagick+| IMatix+| Imlib2+| Info_ZIP+| Intel_ACPI+| Intel+| Interbase_1_0+| IPA+| IPL_1_0+| ISC+| JasPer_2_0+| JSON+| LAL_1_2+| LAL_1_3+| Latex2e+| Leptonica+| LGPL_2_0_only+| LGPL_2_0_or_later+| LGPL_2_1_only+| LGPL_2_1_or_later+| LGPL_3_0_only+| LGPL_3_0_or_later+| LGPLLR+| Libpng+| Libtiff+| LiLiQ_P_1_1+| LiLiQ_R_1_1+| LiLiQ_Rplus_1_1+| Linux_OpenIB+| LPL_1_0+| LPL_1_02+| LPPL_1_0+| LPPL_1_1+| LPPL_1_2+| LPPL_1_3a+| LPPL_1_3c+| MakeIndex+| MirOS+| MIT_0+| MIT_advertising+| MIT_CMU+| MIT_enna+| MIT_feh+| MIT+| MITNFA+| Motosoto+| Mpich2+| MPL_1_0+| MPL_1_1+| MPL_2_0_no_copyleft_exception+| MPL_2_0+| MS_PL+| MS_RL+| MTLL+| Multics+| Mup+| NASA_1_3+| Naumen+| NBPL_1_0+| NCSA+| Net_SNMP+| NetCDF+| Newsletr+| NGPL+| NLOD_1_0+| NLPL+| Nokia+| NOSL+| Noweb+| NPL_1_0+| NPL_1_1+| NPOSL_3_0+| NRL+| NTP+| OCCT_PL+| OCLC_2_0+| ODbL_1_0+| ODC_By_1_0+| OFL_1_0+| OFL_1_1+| OGTSL+| OLDAP_1_1+| OLDAP_1_2+| OLDAP_1_3+| OLDAP_1_4+| OLDAP_2_0_1+| OLDAP_2_0+| OLDAP_2_1+| OLDAP_2_2_1+| OLDAP_2_2_2+| OLDAP_2_2+| OLDAP_2_3+| OLDAP_2_4+| OLDAP_2_5+| OLDAP_2_6+| OLDAP_2_7+| OLDAP_2_8+| OML+| OpenSSL+| OPL_1_0+| OSET_PL_2_1+| OSL_1_0+| OSL_1_1+| OSL_2_0+| OSL_2_1+| OSL_3_0+| PDDL_1_0+| PHP_3_0+| PHP_3_01+| Plexus+| PostgreSQL+| Psfrag+| Psutils+| Python_2_0+| Qhull+| QPL_1_0+| Rdisc+| RHeCos_1_1+| RPL_1_1+| RPL_1_5+| RPSL_1_0+| RSA_MD+| RSCPL+| Ruby+| SAX_PD+| Saxpath+| SCEA+| Sendmail+| SGI_B_1_0+| SGI_B_1_1+| SGI_B_2_0+| SimPL_2_0+| SISSL_1_2+| SISSL+| Sleepycat+| SMLNJ+| SMPPL+| SNIA+| Spencer_86+| Spencer_94+| Spencer_99+| SPL_1_0+| SugarCRM_1_1_3+| SWL+| TCL+| TCP_wrappers+| TMate+| TORQUE_1_1+| TOSL+| TU_Berlin_1_0+| TU_Berlin_2_0+| Unicode_DFS_2015+| Unicode_DFS_2016+| Unicode_TOU+| Unlicense+| UPL_1_0+| Vim+| VOSTROM+| VSL_1_0+| W3C_19980720+| W3C_20150513+| W3C+| Watcom_1_0+| Wsuipa+| WTFPL+| X11+| Xerox+| XFree86_1_1+| Xinetd+| Xnet+| Xpp+| XSkat+| YPL_1_0+| YPL_1_1+| Zed+| Zend_2_0+| Zimbra_1_3+| Zimbra_1_4+| Zlib_acknowledgement+| Zlib+| ZPL_1_1+| ZPL_2_0+| ZPL_2_1 >
dhall/types/Scope.dhall view
@@ -1,1 +1,1 @@-< Public : {} | Private : {} >+< Public | Private >
dhall/utils/GitHub-project.dhall view
@@ -16,7 +16,7 @@ ⫽ { location = Some gitHubRoot , type =- Some ((../types/RepoType.dhall).Git {=})+ Some (../types/RepoType.dhall).Git } ] }
exe/Main.hs view
@@ -1,3 +1,4 @@+{-# language LambdaCase #-} {-# language NoMonomorphismRestriction #-} {-# language NamedFieldPuns #-} {-# language OverloadedStrings #-}@@ -32,6 +33,7 @@ import DhallToCabal.Util ( relativeTo ) import qualified Paths_dhall_to_cabal as Paths +import qualified Data.List.NonEmpty as NonEmpty import qualified Data.Text.IO as StrictText import qualified Data.Text.Prettyprint.Doc as Pretty import qualified Data.Text.Prettyprint.Doc.Render.Text as Pretty@@ -82,6 +84,8 @@ | SPDX | LicenseId | LicenseExceptionId+ | Scope+ | ModuleRenaming deriving (Bounded, Enum, Eq, Ord, Read, Show) @@ -410,7 +414,18 @@ <*> f root +addBinding :: Text -> Dhall.Expr s a -> Dhall.Expr s a -> Dhall.Expr s a+addBinding name val = \case+ Expr.Let bindings body ->+ Expr.Let+ ( Expr.Binding name Nothing val `NonEmpty.cons` bindings )+ body+ expr ->+ Expr.Let+ ( Expr.Binding name Nothing val :| [] )+ expr + printType :: PrintTypeOptions -> IO () printType PrintTypeOptions { .. } = do Pretty.renderIO@@ -450,6 +465,8 @@ SPDX -> Dhall.expected spdxLicense LicenseId -> Dhall.expected spdxLicenseId LicenseExceptionId -> Dhall.expected spdxLicenseExceptionId+ Scope -> Dhall.expected executableScope+ ModuleRenaming -> Dhall.expected moduleRenaming ) makeLetOrImport t val reduced =@@ -457,7 +474,7 @@ name = fromString ( show t ) in if shouldBeImported t && not selfContained then Dhall.subst ( Expr.V name 0 ) ( Expr.Var ( Expr.V "types" 0 ) `Expr.Field` name ) reduced- else Expr.Let (Expr.Binding name Nothing val :| []) reduced+ else addBinding name val reduced factoredType :: Expr.Expr Dhall.Parser.Src Dhall.Import factoredType =@@ -465,19 +482,15 @@ initialState :: CSEState Dhall.Import initialState = CSEState mempty ( dhallType typeToPrint ) - CSEState types expr =+ CSEState types body = execState ( traverse_ step [ minBound .. maxBound ] ) initialState - -- Note: right fold here, though the above traversal is a left- -- fold. We need the types we factor out last to be the- -- outermost-bound.- body = foldr ( uncurry makeLetOrImport ) expr types- importing = if any shouldBeImported ( fst <$> types ) && not selfContained- then Expr.Let- ( Expr.Binding "types" Nothing ( Expr.Embed ( typesLocation dhallFromGitHub ) ) :| [] )+ then addBinding+ "types"+ ( Expr.Embed ( typesLocation dhallFromGitHub ) ) else id in@@ -509,7 +522,11 @@ case liftCSE subrecord name ( dhallType factorType ) expr of Just expr' -> do tell (Any True)- return expr'+ -- Note that the substitution/binding only happens in this+ -- branch, rather than the branch where no expression was+ -- lifted out - otherwise, as the variables aren't shifted+ -- in the latter case, we can get into trouble.+ return $ makeLetOrImport factorType ( dhallType factorType ) expr' Nothing -> return expr @@ -668,17 +685,14 @@ Expr.RecordLit <$> traverse ( `go` v ) fields Expr.Union fields ->- Expr.Union <$> traverse ( `go` v ) fields+ Expr.Union <$> traverse ( traverse ( `go` v ) ) fields Expr.UnionLit n a fields ->- Expr.UnionLit n <$> go a v <*> traverse ( `go` v ) fields+ Expr.UnionLit n <$> go a v <*> traverse ( traverse ( `go` v ) ) fields Expr.Merge a b t -> Expr.Merge <$> go a v <*> go b v <*> traverse ( `go` v ) t - Expr.Constructors e ->- Expr.Constructors <$> go e v- Expr.Field e f -> Expr.Field <$> go e v <*> pure f @@ -763,6 +777,9 @@ Expr.TextLit{} -> pure e + Expr.TextShow ->+ pure e+ Expr.List -> pure e @@ -814,8 +831,9 @@ where withPreludeImport =- Expr.Let (Expr.Binding "prelude" Nothing- ( Expr.Embed ( preludeLocation dhallFromGitHub ) ) :| [])+ addBinding+ "prelude"+ ( Expr.Embed ( preludeLocation dhallFromGitHub ) ) expr :: Expr.Expr Dhall.Parser.Src Dhall.Import expr = getDefault
golden-tests/cabal-to-dhall/SPDX.dhall view
@@ -12,11 +12,11 @@ ( prelude.SPDX.and ( prelude.SPDX.or ( prelude.SPDX.license- (types.LicenseId.AGPL_3_0_or_later {=})- (Some (types.LicenseExceptionId.Classpath_exception_2_0 {=}))+ types.LicenseId.AGPL_3_0_or_later+ (Some types.LicenseExceptionId.Classpath_exception_2_0) ) ( prelude.SPDX.licenseVersionOrLater- (types.LicenseId.Apache_2_0 {=})+ types.LicenseId.Apache_2_0 (None types.LicenseExceptionId) ) )
golden-tests/cabal-to-dhall/conditional-dependencies.dhall view
@@ -13,14 +13,14 @@ Some ( λ(config : types.Config) → if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "8.2")) (prelude.laterVersion (prelude.v "8.2")) ) then if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "8.4")) (prelude.laterVersion (prelude.v "8.4"))@@ -42,7 +42,7 @@ } else if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "8.4")) (prelude.laterVersion (prelude.v "8.4"))@@ -61,5 +61,5 @@ } ) , license =- types.License.Unspecified {=}+ types.License.Unspecified }
golden-tests/cabal-to-dhall/gh-36.dhall view
@@ -24,18 +24,18 @@ Some ( λ(config : types.Config) → if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "0.0.9.7")) (prelude.laterVersion (prelude.v "0.0.9.7")) ) then if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC (prelude.earlierVersion (prelude.v "0.7.0.2")) then if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "0.0.9")) (prelude.laterVersion (prelude.v "0.0.9"))@@ -76,7 +76,7 @@ } else if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "0.0.9")) (prelude.laterVersion (prelude.v "0.0.9"))@@ -109,11 +109,11 @@ ⫽ { cpp-options = [ "-DINTEROP" ] } else if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC (prelude.earlierVersion (prelude.v "0.7.0.2")) then if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "0.0.9")) (prelude.laterVersion (prelude.v "0.0.9"))@@ -148,7 +148,7 @@ ⫽ { cpp-options = [ "-DPURE_JAVA_WITH" ] } else if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC ( prelude.unionVersionRanges (prelude.thisVersion (prelude.v "0.0.9")) (prelude.laterVersion (prelude.v "0.0.9"))
golden-tests/cabal-to-dhall/mixins-no-signatures.dhall view
@@ -16,9 +16,9 @@ "foo" , renaming = { provides =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default , requires =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default } } , { package =@@ -35,7 +35,7 @@ , { rename = "Third.Module", to = "Renamed" } ] , requires =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default } } , { package =@@ -45,7 +45,7 @@ types.ModuleRenaming.hiding [ "Hidden", "Also.Hidden" ] , requires =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default } } ]
golden-tests/cabal-to-dhall/sourcerepo-defaults.dhall view
@@ -9,18 +9,14 @@ prelude.v "0" , source-repos = [ prelude.defaults.SourceRepo- ⫽ { type =- Some (types.RepoType.Git {=})- , location =- Some "example.com"- }+ ⫽ { type = Some types.RepoType.Git, location = Some "example.com" } , prelude.defaults.SourceRepo ⫽ { type =- Some (types.RepoType.Darcs {=})+ Some types.RepoType.Darcs , location = Some "example.org" , kind =- types.RepoKind.RepoThis {=}+ types.RepoKind.RepoThis } ] }
+ golden-tests/cabal-to-dhall/unknown-license.cabal view
@@ -0,0 +1,4 @@+cabal-version: 1.12+name: test+version: 1.0+license: MYUnknownLicense
+ golden-tests/cabal-to-dhall/unknown-license.dhall view
@@ -0,0 +1,14 @@+let prelude = ./../../dhall/prelude.dhall++let types = ./../../dhall/types.dhall++in prelude.defaults.Package+ ⫽ { name =+ "test"+ , version =+ prelude.v "1.0"+ , cabal-version =+ prelude.v "1.12"+ , license =+ types.License.Unknown "MYUnknownLicense"+ }
golden-tests/dhall-to-cabal/SPDX.dhall view
@@ -14,12 +14,12 @@ ( prelude.SPDX.and ( prelude.SPDX.or ( prelude.SPDX.license- (types.LicenseId.AGPL_3_0_or_later {=})+ types.LicenseId.AGPL_3_0_or_later prelude.SPDX.noException ) ( prelude.SPDX.licenseVersionOrLater- (types.LicenseId.Apache_2_0 {=})- (Some (types.LicenseExceptionId.Classpath_exception_2_0 {=}))+ types.LicenseId.Apache_2_0+ (Some types.LicenseExceptionId.Classpath_exception_2_0) ) ) ( prelude.SPDX.or
golden-tests/dhall-to-cabal/allrightsreserved-2.0.dhall view
@@ -10,7 +10,7 @@ , cabal-version = prelude.v "2.0" , license =- types.License.AllRightsReserved {=}+ types.License.AllRightsReserved , library = prelude.unconditional.library prelude.defaults.Library }
golden-tests/dhall-to-cabal/allrightsreserved-2.2.dhall view
@@ -10,7 +10,7 @@ , cabal-version = prelude.v "2.2" , license =- types.License.AllRightsReserved {=}+ types.License.AllRightsReserved , library = prelude.unconditional.library prelude.defaults.Library }
golden-tests/dhall-to-cabal/compiler-options-order.dhall view
@@ -7,7 +7,7 @@ let ghcImpl = λ(cfg : types.Config) → λ(ver : types.VersionRange)- → cfg.impl (types.Compiler.GHC {=}) ver+ → cfg.impl types.Compiler.GHC ver in ../../dhall/defaults/Package.dhall ⫽ { name =
golden-tests/dhall-to-cabal/conditional-dependencies.dhall view
@@ -7,7 +7,7 @@ let ghcImpl = λ(cfg : types.Config) → λ(ver : types.VersionRange)- → cfg.impl (types.Compiler.GHC {=}) ver+ → cfg.impl types.Compiler.GHC ver in ../../dhall/defaults/Package.dhall ⫽ { name =
golden-tests/dhall-to-cabal/dhall-to-cabal.dhall view
@@ -131,7 +131,7 @@ , "dhall/types/SetupBuildInfo.dhall" ] , license =- types.License.MIT {=}+ types.License.MIT , license-files = [ "LICENSE" ] , version =@@ -175,7 +175,7 @@ , "Dhall.Extra" ] , default-language =- Some (types.Language.Haskell2010 {=})+ Some types.Language.Haskell2010 } ) , executables =@@ -198,7 +198,7 @@ , other-extensions = [ types.Extension.NamedFieldPuns True ] , default-language =- Some (types.Language.Haskell2010 {=})+ Some types.Language.Haskell2010 } ) , prelude.unconditional.executable@@ -223,7 +223,7 @@ , other-extensions = [ types.Extension.NamedFieldPuns True ] , default-language =- Some (types.Language.Haskell2010 {=})+ Some types.Language.Haskell2010 } ) ]@@ -247,7 +247,7 @@ , type = types.TestType.exitcode-stdio { main-is = "GoldenTests.hs" } , default-language =- Some (types.Language.Haskell2010 {=})+ Some types.Language.Haskell2010 } ) ]
golden-tests/dhall-to-cabal/gh-53.dhall view
@@ -24,7 +24,7 @@ Some ( λ(config : types.Config) → if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC (prelude.orLaterVersion (prelude.v "0.0.9")) then if config.flag "wai-servlet-debug"
golden-tests/dhall-to-cabal/gh-55.dhall view
@@ -7,7 +7,7 @@ let ghcImpl = λ(cfg : types.Config) → λ(ver : types.VersionRange)- → cfg.impl (types.Compiler.GHC {=}) ver+ → cfg.impl types.Compiler.GHC ver in ./../../dhall/defaults/Package.dhall ⫽ { name =
golden-tests/dhall-to-cabal/map-source-repo.dhall view
@@ -5,7 +5,7 @@ let updateRepo = prelude.utils.mapSourceRepos ( λ(srcRepo : types.SourceRepo)- → srcRepo ⫽ { tag = Some "1.0.0", kind = types.RepoKind.RepoThis {=} }+ → srcRepo ⫽ { tag = Some "1.0.0", kind = types.RepoKind.RepoThis } ) let project = prelude.utils.GitHub-project { owner = "owner", repo = "repo" }
golden-tests/dhall-to-cabal/mixins-no-signatures.dhall view
@@ -16,9 +16,9 @@ "foo" , renaming = { provides =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default , requires =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default } } , { package =@@ -35,7 +35,7 @@ , { rename = "Third.Module", to = "Renamed" } ] , requires =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default } } , { package =@@ -45,7 +45,7 @@ types.ModuleRenaming.hiding [ "Hidden", "Also.Hidden" ] , requires =- types.ModuleRenaming.default {=}+ types.ModuleRenaming.default } } ]
golden-tests/dhall-to-cabal/nested-conditions.dhall view
@@ -18,7 +18,7 @@ ⫽ { GHC = [ "-Weverything" ] # ( if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC (prelude.orLaterVersion (v "8.2")) then [ "-Wno-redundant-constraints" ] : List Text@@ -26,7 +26,7 @@ else [] : List Text ) # ( if config.impl- (types.Compiler.GHC {=})+ types.Compiler.GHC (prelude.orLaterVersion (v "8.4")) then [ "-Wno-missing-export-lists" ] : List Text
lib/CabalToDhall.hs view
@@ -318,10 +318,7 @@ where specificFields = Map.singleton "scope"- ( Expr.App- ( resolve PreludeConstructorsScope `Expr.Field` "Public" )- ( Expr.RecordLit mempty )- )+ ( resolve PreludeConstructorsScope `Expr.Field` "Public" ) packageDefault :: Default s a@@ -371,9 +368,7 @@ ( generaliseDeclared library ) ) , ( "license"- , Expr.App- ( resolve PreludeConstructorsLicense `Expr.Field` "AllRightsReserved" )- ( Expr.RecordLit mempty )+ , resolve PreludeConstructorsLicense `Expr.Field` "AllRightsReserved" ) , emptyListDefault "license-files" Expr.Text , textFieldDefault "maintainer" ""@@ -413,9 +408,7 @@ , emptyOptionalDefault "tag" Expr.Text , emptyOptionalDefault "subdir" Expr.Text , ( "kind"- , Expr.App- ( resolve PreludeConstructorsRepoKind `Expr.Field` "RepoHead" )- ( Expr.RecordLit mempty )+ , resolve PreludeConstructorsRepoKind `Expr.Field` "RepoHead" ) ] @@ -621,35 +614,35 @@ Right ( Cabal.LGPL v ) -> license "LGPL" ( Dhall.embed ( maybeToDhall versionToDhall ) v ) Right Cabal.BSD2 ->- license "BSD2" ( Expr.RecordLit mempty )+ licenseNullary "BSD2" Right Cabal.BSD3 ->- license "BSD3" ( Expr.RecordLit mempty )+ licenseNullary "BSD3" Right Cabal.BSD4 ->- license "BSD4" ( Expr.RecordLit mempty )+ licenseNullary "BSD4" Right Cabal.MIT ->- license "MIT" ( Expr.RecordLit mempty )+ licenseNullary "MIT" Right Cabal.ISC ->- license "ISC" ( Expr.RecordLit mempty )+ licenseNullary "ISC" Right ( Cabal.MPL v ) -> license "MPL" ( Dhall.embed versionToDhall v ) Right ( Cabal.Apache v ) -> license "Apache" ( Dhall.embed ( maybeToDhall versionToDhall ) v ) Right Cabal.PublicDomain ->- license "PublicDomain" ( Expr.RecordLit mempty )+ licenseNullary "PublicDomain" Right Cabal.AllRightsReserved ->- license "AllRightsReserved" ( Expr.RecordLit mempty )+ licenseNullary "AllRightsReserved" -- Note: SPDX.NONE is what Cabal reports for a file without -- a 'license' field, even for pre-2.2 spec versions. Left SPDX.NONE ->- license "AllRightsReserved" ( Expr.RecordLit mempty )+ licenseNullary "AllRightsReserved" Right Cabal.UnspecifiedLicense ->- license "Unspecified" ( Expr.RecordLit mempty )+ licenseNullary "Unspecified" Right ( Cabal.UnknownLicense "UnspecifiedLicense" ) ->- license "Unspecified" ( Expr.RecordLit mempty )+ licenseNullary "Unspecified" Right ( Cabal.UnknownLicense l ) ->- license "Unspecified" ( Expr.TextLit (Expr.Chunks [] (StrictText.pack l)) )+ license "Unknown" ( Expr.TextLit (Expr.Chunks [] (StrictText.pack l)) ) Right Cabal.OtherLicense ->- license "Other" ( Expr.RecordLit mempty )+ licenseNullary "Other" Left ( SPDX.License x ) -> license "SPDX" ( Dhall.embed spdxLicenseExpressionToDhall x ) , Dhall.declared =@@ -659,6 +652,8 @@ license name = Expr.App ( Expr.Var "types" `Expr.Field` "License" `Expr.Field` name )+ licenseNullary name =+ Expr.Var "types" `Expr.Field` "License" `Expr.Field` name spdxLicenseExpressionToDhall :: Dhall.InputType SPDX.LicenseExpression spdxLicenseExpressionToDhall =@@ -722,9 +717,7 @@ spdxLicenseIdToDhall = Dhall.InputType { Dhall.embed = \ident ->- Expr.App- ( Expr.Var "types" `Expr.Field` "LicenseId" `Expr.Field` identName ident )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "LicenseId" `Expr.Field` identName ident , Dhall.declared = Expr.Var "types" `Expr.Field` "LicenseId" }@@ -739,9 +732,7 @@ spdxLicenseExceptionIdToDhall = Dhall.InputType { Dhall.embed = \ident ->- Expr.App- ( Expr.Var "types" `Expr.Field` "LicenseExceptionId" `Expr.Field` identName ident )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "LicenseExceptionId" `Expr.Field` identName ident , Dhall.declared = Expr.Var "types" `Expr.Field` "LicenseExceptionId" }@@ -775,9 +766,9 @@ error $ "Union did not match anything. Given " ++ show a ( First ( Just ( k, v ) ), alts ) ->- Expr.UnionLit k v alts+ Expr.UnionLit k v ( Just <$> alts ) , Dhall.declared =- sortExpr ( Expr.Union t )+ sortExpr ( Expr.Union ( Just <$> t ) ) } @@ -833,50 +824,52 @@ let constructor k v = Expr.App ( Expr.Var "types" `Expr.Field` "Compiler" `Expr.Field` k ) v+ nullary k =+ Expr.Var "types" `Expr.Field` "Compiler" `Expr.Field` k in Dhall.InputType { Dhall.embed = \case Cabal.Eta ->- constructor "Eta" ( Expr.RecordLit mempty )+ nullary "Eta" Cabal.GHC ->- constructor "GHC" ( Expr.RecordLit mempty )+ nullary "GHC" Cabal.GHCJS ->- constructor "GHCJS" ( Expr.RecordLit mempty )+ nullary "GHCJS" Cabal.HBC ->- constructor "HBC" ( Expr.RecordLit mempty )+ nullary "HBC" Cabal.HaskellSuite v -> constructor "HaskellSuite" ( Expr.Record ( Map.singleton "_1" ( dhallString v ) ) ) Cabal.Helium ->- constructor "Helium" ( Expr.RecordLit mempty )+ nullary "Helium" Cabal.Hugs ->- constructor "Hugs" ( Expr.RecordLit mempty )+ nullary "Hugs" Cabal.JHC ->- constructor "JHC" ( Expr.RecordLit mempty )+ nullary "JHC" Cabal.LHC ->- constructor "LHC" ( Expr.RecordLit mempty )+ nullary "LHC" Cabal.NHC ->- constructor "NHC" ( Expr.RecordLit mempty )+ nullary "NHC" Cabal.OtherCompiler v -> constructor "OtherCompiler" ( Expr.Record ( Map.singleton "_1" ( dhallString v ) ) ) Cabal.UHC ->- constructor "UHC" ( Expr.RecordLit mempty )+ nullary "UHC" Cabal.YHC ->- constructor "YHC" ( Expr.RecordLit mempty )+ nullary "YHC" , Dhall.declared = Expr.Var "types" `Expr.Field` "Compiler" }@@ -954,13 +947,9 @@ Dhall.InputType { Dhall.embed = \case Cabal.RepoThis ->- Expr.App- ( Expr.Var "types" `Expr.Field` "RepoKind" `Expr.Field` "RepoThis" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "RepoKind" `Expr.Field` "RepoThis" Cabal.RepoHead ->- Expr.App- ( Expr.Var "types" `Expr.Field` "RepoKind" `Expr.Field` "RepoHead" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "RepoKind" `Expr.Field` "RepoHead" Cabal.RepoKindUnknown str -> Expr.App ( Expr.Var "types" `Expr.Field` "RepoKind" `Expr.Field` "RepoThis" )@@ -975,21 +964,21 @@ Dhall.InputType { Dhall.embed = \case Cabal.Darcs ->- Expr.App ( constr "Darcs" ) ( Expr.RecordLit mempty )+ constr "Darcs" Cabal.Git ->- Expr.App ( constr "Git" ) ( Expr.RecordLit mempty )+ constr "Git" Cabal.SVN ->- Expr.App ( constr "SVN" ) ( Expr.RecordLit mempty )+ constr "SVN" Cabal.CVS ->- Expr.App ( constr "CVS" ) ( Expr.RecordLit mempty )+ constr "CVS" Cabal.Mercurial ->- Expr.App ( constr "Mercurial" ) ( Expr.RecordLit mempty )+ constr "Mercurial" Cabal.GnuArch ->- Expr.App ( constr "GnuArch" ) ( Expr.RecordLit mempty )+ constr "GnuArch" Cabal.Monotone ->- Expr.App ( constr "Monotone" ) ( Expr.RecordLit mempty )+ constr "Monotone" Cabal.Bazaar ->- Expr.App ( constr "Bazaar" ) ( Expr.RecordLit mempty )+ constr "Bazaar" Cabal.OtherRepoType str -> Expr.App ( constr "OtherRepoType" )@@ -1015,24 +1004,16 @@ Dhall.InputType { Dhall.embed = \case Cabal.Simple ->- Expr.App- ( Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Simple" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Simple" Cabal.Configure ->- Expr.App- ( Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Configure" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Configure" Cabal.Custom ->- Expr.App- ( Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Custom" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Custom" Cabal.Make ->- Expr.App- ( Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Make" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "BuildType" `Expr.Field` "Make" , Dhall.declared = Expr.Var "types" `Expr.Field` "BuildType"@@ -1197,84 +1178,52 @@ Dhall.InputType { Dhall.embed = \case Cabal.Linux ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Linux" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Linux" Cabal.Windows ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Windows" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Windows" Cabal.OSX ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "OSX" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "OSX" Cabal.FreeBSD ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "FreeBSD" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "FreeBSD" Cabal.OpenBSD ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "OpenBSD" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "OpenBSD" Cabal.NetBSD ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "NetBSD" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "NetBSD" Cabal.DragonFly ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "DragonFly" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "DragonFly" Cabal.Solaris ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Solaris" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Solaris" Cabal.AIX ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "AIX" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "AIX" Cabal.HPUX ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "HPUX" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "HPUX" Cabal.IRIX ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "IRIX" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "IRIX" Cabal.HaLVM ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "HaLVM" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "HaLVM" Cabal.Hurd ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Hurd" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Hurd" Cabal.IOS ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "IOS" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "IOS" Cabal.Android ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Android" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Android" Cabal.Ghcjs ->- Expr.App- ( Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Ghcjs" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "OS" `Expr.Field` "Ghcjs" Cabal.OtherOS os -> Expr.App@@ -1529,9 +1478,7 @@ ) ) Cabal.DefaultRenaming ->- Expr.App- ( Expr.Var "types" `Expr.Field` "ModuleRenaming" `Expr.Field` "default" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "ModuleRenaming" `Expr.Field` "default" Cabal.HidingRenaming hidden -> Expr.App ( Expr.Var "types" `Expr.Field` "ModuleRenaming" `Expr.Field` "hiding" )@@ -1627,13 +1574,9 @@ Dhall.InputType { Dhall.embed = \case Cabal.ExecutablePublic ->- Expr.App- ( Expr.Var "types" `Expr.Field` "Scope" `Expr.Field` "Public" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "Scope" `Expr.Field` "Public" Cabal.ExecutablePrivate ->- Expr.App- ( Expr.Var "types" `Expr.Field` "Scope" `Expr.Field` "Private" )- ( Expr.RecordLit mempty )+ Expr.Var "types" `Expr.Field` "Scope" `Expr.Field` "Private" , Dhall.declared = Expr.Var "types" `Expr.Field` "Scope" }
lib/Dhall/Extra.hs view
@@ -5,8 +5,7 @@ {-# language RecordWildCards #-} module Dhall.Extra- ( makeUnion- , validateType+ ( validateType , sortExpr ) where@@ -15,30 +14,10 @@ import Data.List ( sortBy ) import Data.Ord ( comparing ) -import qualified Data.Text as StrictText import qualified Dhall import qualified Dhall.Core as Dhall ( Expr ) import qualified Dhall.Core as Expr ( Expr(..) ) import qualified Dhall.Map as Map---makeUnion :: Map.Map StrictText.Text ( Dhall.Type a ) -> Dhall.Type a-makeUnion alts =- let- extract expr = do- Expr.UnionLit ctor v _ <-- return expr-- t <-- Map.lookup ctor alts-- Dhall.extract t v-- expected =- sortExpr ( Expr.Union ( Dhall.expected <$> alts ) )-- in Dhall.Type { .. }- validateType :: Dhall.Type ( Maybe a ) -> Dhall.Type a
lib/DhallLocation.hs view
@@ -44,7 +44,6 @@ ) Nothing Nothing- Nothing ) } , Dhall.Core.importMode =@@ -66,7 +65,6 @@ ( Dhall.Core.Directory [ "dhall", version, "dhall-to-cabal", "dhall-lang" ] ) "types.dhall" )- Nothing Nothing Nothing )
lib/DhallToCabal.hs view
@@ -34,6 +34,8 @@ , version , configRecordType , buildInfoType+ , executableScope+ , moduleRenaming , sortExpr ) where@@ -419,20 +421,16 @@ testSuiteInterface :: Dhall.Type Cabal.TestSuiteInterface-testSuiteInterface =- makeUnion- ( Map.fromList- [ ( "exitcode-stdio"- , Cabal.TestSuiteExeV10 ( Cabal.mkVersion [ 1, 0 ] )- <$> Dhall.record ( Dhall.field "main-is" Dhall.string )- )- , ( "detailed"- , Cabal.TestSuiteLibV09 ( Cabal.mkVersion [ 0, 9 ] )- <$> Dhall.record ( Dhall.field "module" moduleName )- )- ]- )-+testSuiteInterface = Dhall.union+ ( mconcat+ [ Cabal.TestSuiteExeV10 ( Cabal.mkVersion [ 1, 0 ] )+ <$> Dhall.constructor "exitcode-stdio"+ ( Dhall.record ( Dhall.field "main-is" Dhall.string ) )+ , Cabal.TestSuiteLibV09 ( Cabal.mkVersion [ 0, 9 ] )+ <$> Dhall.constructor "detailed"+ ( Dhall.record ( Dhall.field "module" moduleName ) )+ ]+ ) @@ -490,13 +488,12 @@ foreignLibType :: Dhall.Type Cabal.ForeignLibType-foreignLibType =- makeUnion- ( Map.fromList- [ ( "Shared", Cabal.ForeignLibNativeShared <$ Dhall.unit )- , ( "Static", Cabal.ForeignLibNativeStatic <$ Dhall.unit )- ]- )+foreignLibType = Dhall.union+ ( mconcat+ [ Cabal.ForeignLibNativeShared <$ Dhall.constructor "Shared" Dhall.unit+ , Cabal.ForeignLibNativeStatic <$ Dhall.constructor "Static" Dhall.unit+ ]+ ) @@ -707,27 +704,26 @@ license :: Dhall.Type (Either SPDX.License Cabal.License)-license =- makeUnion- ( Map.fromList- [ ( "GPL", Right . Cabal.GPL <$> Dhall.maybe version )- , ( "AGPL", Right . Cabal.AGPL <$> Dhall.maybe version )- , ( "LGPL", Right . Cabal.LGPL <$> Dhall.maybe version )- , ( "BSD2", Right Cabal.BSD2 <$ Dhall.unit )- , ( "BSD3", Right Cabal.BSD3 <$ Dhall.unit )- , ( "BSD4", Right Cabal.BSD4 <$ Dhall.unit )- , ( "MIT", Right Cabal.MIT <$ Dhall.unit )- , ( "ISC", Right Cabal.ISC <$ Dhall.unit )- , ( "MPL", Right . Cabal.MPL <$> version )- , ( "Apache", Right . Cabal.Apache <$> Dhall.maybe version )- , ( "PublicDomain", Right Cabal.PublicDomain <$ Dhall.unit )- , ( "AllRightsReserved", Right Cabal.AllRightsReserved<$ Dhall.unit )- , ( "Unspecified", Right Cabal.UnspecifiedLicense <$ Dhall.unit )- , ( "Unknown", Right . Cabal.UnknownLicense <$> Dhall.string )- , ( "Other", Right Cabal.OtherLicense <$ Dhall.unit )- , ( "SPDX", Left . SPDX.License <$> spdxLicense )- ]- )+license = Dhall.union+ ( mconcat+ [ Right . Cabal.GPL <$> Dhall.constructor "GPL" ( Dhall.maybe version )+ , Right . Cabal.AGPL <$> Dhall.constructor "AGPL" ( Dhall.maybe version )+ , Right . Cabal.LGPL <$> Dhall.constructor "LGPL" ( Dhall.maybe version )+ , Right Cabal.BSD2 <$ Dhall.constructor "BSD2" Dhall.unit+ , Right Cabal.BSD3 <$ Dhall.constructor "BSD3" Dhall.unit+ , Right Cabal.BSD4 <$ Dhall.constructor "BSD4" Dhall.unit+ , Right Cabal.MIT <$ Dhall.constructor "MIT" Dhall.unit+ , Right Cabal.ISC <$ Dhall.constructor "ISC" Dhall.unit+ , Right . Cabal.MPL <$> Dhall.constructor "MPL" version+ , Right . Cabal.Apache <$> Dhall.constructor "Apache" ( Dhall.maybe version )+ , Right Cabal.PublicDomain <$ Dhall.constructor "PublicDomain" Dhall.unit+ , Right Cabal.AllRightsReserved <$ Dhall.constructor "AllRightsReserved" Dhall.unit+ , Right Cabal.UnspecifiedLicense <$ Dhall.constructor "Unspecified" Dhall.unit+ , Right . Cabal.UnknownLicense <$> Dhall.constructor "Unknown" Dhall.string+ , Right Cabal.OtherLicense <$ Dhall.constructor "Other" Dhall.unit+ , Left . SPDX.License <$> Dhall.constructor "SPDX" spdxLicense+ ]+ ) spdxLicense :: Dhall.Type SPDX.LicenseExpression@@ -928,13 +924,12 @@ executableScope :: Dhall.Type Cabal.ExecutableScope-executableScope =- makeUnion- ( Map.fromList- [ ( "Public", Cabal.ExecutablePublic <$ Dhall.unit )- , ( "Private", Cabal.ExecutablePrivate <$ Dhall.unit )- ]- )+executableScope = Dhall.union+ ( mconcat+ [ Cabal.ExecutablePublic <$ Dhall.constructor "Public" Dhall.unit+ , Cabal.ExecutablePrivate <$ Dhall.constructor "Private" Dhall.unit+ ]+ ) @@ -964,11 +959,8 @@ foreignLibOption :: Dhall.Type Cabal.ForeignLibOption-foreignLibOption =- makeUnion- ( Map.fromList- [ ( "Standalone", Cabal.ForeignLibStandalone <$ Dhall.unit ) ]- )+foreignLibOption = Dhall.union $+ Cabal.ForeignLibStandalone <$ Dhall.constructor "Standalone" Dhall.unit versionInfo :: Dhall.Type Cabal.LibVersionInfo@@ -985,40 +977,20 @@ extension :: Dhall.Type Cabal.Extension extension = let- knownExtension =- sortType Dhall.genericAuto-- unitType =- Expr.Record mempty-- extract expr = do- Expr.UnionLit k v alts <-- return expr-- ext <-- Dhall.extract- knownExtension- ( Expr.UnionLit k ( Expr.RecordLit mempty ) ( unitType <$ alts ) )-- case v of- Expr.BoolLit True ->- return ( Cabal.EnableExtension ext )-- Expr.BoolLit False ->- return ( Cabal.DisableExtension ext )-- _ ->- Nothing-- expected =- case Dhall.expected knownExtension of- Expr.Union alts ->- sortExpr ( Expr.Union ( Expr.Bool <$ alts ) )+ extName :: Cabal.KnownExtension -> StrictText.Text+ extName e =+ StrictText.pack ( show e ) - _ ->- error "Could not derive extension type"+ enableDisable ext enabled = if enabled+ then Cabal.EnableExtension ext+ else Cabal.DisableExtension ext - in Dhall.Type { .. }+ constr :: Cabal.KnownExtension -> Dhall.UnionType Cabal.Extension+ constr ext = Dhall.constructor+ ( extName ext )+ ( enableDisable ext <$> Dhall.bool )+ in+ Dhall.union ( foldMap constr [ minBound .. maxBound ] ) @@ -1329,26 +1301,21 @@ moduleRenaming :: Dhall.Type Cabal.ModuleRenaming-moduleRenaming =- makeUnion- ( Map.fromList- [ ( "renaming"- , fmap Cabal.ModuleRenaming- ( Dhall.list- ( Dhall.record- ( (,) <$> Dhall.field "rename" moduleName <*> Dhall.field "to" moduleName )+moduleRenaming = Dhall.union+ ( mconcat+ [ Cabal.ModuleRenaming+ <$> Dhall.constructor "renaming"+ ( Dhall.list+ ( Dhall.record+ ( (,) <$> Dhall.field "rename" moduleName <*> Dhall.field "to" moduleName )+ ) )- )- )- , ( "default"- , Dhall.record ( pure Cabal.DefaultRenaming )- )- , ( "hiding"- , fmap Cabal.HidingRenaming- ( Dhall.list moduleName )- )- ]- )+ , Cabal.DefaultRenaming+ <$ Dhall.constructor "default" Dhall.unit+ , Cabal.HidingRenaming+ <$> Dhall.constructor "hiding" ( Dhall.list moduleName )+ ]+ ) sortType :: Dhall.Type a -> Dhall.Type a