dhall-lang / dhall-to-cabal

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

Factor build info #64

Closed ocharles closed 6 years ago

ocharles commented 6 years ago

Fixes #60 .

Here's the new --print-type:

    let Version = ∀(Version : Type) → ∀(v : Text → Version) → Version

in  let VersionRange =
            ∀(VersionRange : Type)
          → ∀(anyVersion : VersionRange)
          → ∀(noVersion : VersionRange)
          → ∀(thisVersion : Version → VersionRange)
          → ∀(notThisVersion : Version → VersionRange)
          → ∀(laterVersion : Version → VersionRange)
          → ∀(earlierVersion : Version → VersionRange)
          → ∀(orLaterVersion : Version → VersionRange)
          → ∀(orEarlierVersion : Version → VersionRange)
          → ∀(withinVersion : Version → VersionRange)
          → ∀(majorBoundVersion : Version → VersionRange)
          → ∀(unionVersionRanges : VersionRange → VersionRange → VersionRange)
          → ∀ ( intersectVersionRanges
              : VersionRange → VersionRange → VersionRange
              )
          → ∀ ( differenceVersionRanges
              : VersionRange → VersionRange → VersionRange
              )
          → ∀(invertVersionRange : VersionRange → VersionRange)
          → VersionRange

in  let BuildType =
          < Configure :
              {}
          | Custom :
              {}
          | Make :
              {}
          | Simple :
              {}
          | UnknownBuildType :
              { _1 : Text }
          >

in  let License =
          < AGPL :
              Optional Version
          | AllRightsReserved :
              {}
          | Apache :
              Optional Version
          | BSD2 :
              {}
          | BSD3 :
              {}
          | BSD4 :
              {}
          | GPL :
              Optional Version
          | ISC :
              {}
          | LGPL :
              Optional Version
          | MIT :
              {}
          | MPL :
              Version
          | Other :
              {}
          | PublicDomain :
              {}
          | Unspecified :
              {}
          >

in  let Language =
          < Haskell2010 :
              {}
          | Haskell98 :
              {}
          | UnknownLanguage :
              { _1 : Text }
          >

in  let Arch =
          < Alpha :
              {}
          | Arm :
              {}
          | Hppa :
              {}
          | I386 :
              {}
          | IA64 :
              {}
          | JavaScript :
              {}
          | M68k :
              {}
          | Mips :
              {}
          | OtherArch :
              { _1 : Text }
          | PPC :
              {}
          | PPC64 :
              {}
          | Rs6000 :
              {}
          | S390 :
              {}
          | SH :
              {}
          | Sparc :
              {}
          | Vax :
              {}
          | X86_64 :
              {}
          >

in  let CompilerOptions =
          { 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
          }

in  let Extension =
          < AllowAmbiguousTypes :
              Bool
          | ApplicativeDo :
              Bool
          | Arrows :
              Bool
          | AutoDeriveTypeable :
              Bool
          | BangPatterns :
              Bool
          | BinaryLiterals :
              Bool
          | CApiFFI :
              Bool
          | CPP :
              Bool
          | ConstrainedClassMethods :
              Bool
          | ConstraintKinds :
              Bool
          | DataKinds :
              Bool
          | DatatypeContexts :
              Bool
          | DefaultSignatures :
              Bool
          | DeriveAnyClass :
              Bool
          | DeriveDataTypeable :
              Bool
          | DeriveFoldable :
              Bool
          | DeriveFunctor :
              Bool
          | DeriveGeneric :
              Bool
          | DeriveLift :
              Bool
          | DeriveTraversable :
              Bool
          | DisambiguateRecordFields :
              Bool
          | DoAndIfThenElse :
              Bool
          | DoRec :
              Bool
          | DuplicateRecordFields :
              Bool
          | EmptyCase :
              Bool
          | EmptyDataDecls :
              Bool
          | ExistentialQuantification :
              Bool
          | ExplicitForAll :
              Bool
          | ExplicitNamespaces :
              Bool
          | ExtendedDefaultRules :
              Bool
          | ExtensibleRecords :
              Bool
          | FlexibleContexts :
              Bool
          | FlexibleInstances :
              Bool
          | ForeignFunctionInterface :
              Bool
          | FunctionalDependencies :
              Bool
          | GADTSyntax :
              Bool
          | GADTs :
              Bool
          | GHCForeignImportPrim :
              Bool
          | GeneralizedNewtypeDeriving :
              Bool
          | Generics :
              Bool
          | HereDocuments :
              Bool
          | ImplicitParams :
              Bool
          | ImplicitPrelude :
              Bool
          | ImpredicativeTypes :
              Bool
          | IncoherentInstances :
              Bool
          | InstanceSigs :
              Bool
          | InterruptibleFFI :
              Bool
          | JavaScriptFFI :
              Bool
          | KindSignatures :
              Bool
          | LambdaCase :
              Bool
          | LiberalTypeSynonyms :
              Bool
          | MagicHash :
              Bool
          | MonadComprehensions :
              Bool
          | MonadFailDesugaring :
              Bool
          | MonoLocalBinds :
              Bool
          | MonoPatBinds :
              Bool
          | MonomorphismRestriction :
              Bool
          | MultiParamTypeClasses :
              Bool
          | MultiWayIf :
              Bool
          | NPlusKPatterns :
              Bool
          | NamedFieldPuns :
              Bool
          | NamedWildCards :
              Bool
          | NegativeLiterals :
              Bool
          | NewQualifiedOperators :
              Bool
          | NondecreasingIndentation :
              Bool
          | NullaryTypeClasses :
              Bool
          | NumDecimals :
              Bool
          | OverlappingInstances :
              Bool
          | OverloadedLabels :
              Bool
          | OverloadedLists :
              Bool
          | OverloadedStrings :
              Bool
          | PackageImports :
              Bool
          | ParallelArrays :
              Bool
          | ParallelListComp :
              Bool
          | PartialTypeSignatures :
              Bool
          | PatternGuards :
              Bool
          | PatternSignatures :
              Bool
          | PatternSynonyms :
              Bool
          | PolyKinds :
              Bool
          | PolymorphicComponents :
              Bool
          | PostfixOperators :
              Bool
          | QuasiQuotes :
              Bool
          | Rank2Types :
              Bool
          | RankNTypes :
              Bool
          | RebindableSyntax :
              Bool
          | RecordPuns :
              Bool
          | RecordWildCards :
              Bool
          | RecursiveDo :
              Bool
          | RegularPatterns :
              Bool
          | RelaxedPolyRec :
              Bool
          | RestrictedTypeSynonyms :
              Bool
          | RoleAnnotations :
              Bool
          | Safe :
              Bool
          | SafeImports :
              Bool
          | ScopedTypeVariables :
              Bool
          | StandaloneDeriving :
              Bool
          | StaticPointers :
              Bool
          | Strict :
              Bool
          | StrictData :
              Bool
          | TemplateHaskell :
              Bool
          | TemplateHaskellQuotes :
              Bool
          | TraditionalRecordSyntax :
              Bool
          | TransformListComp :
              Bool
          | Trustworthy :
              Bool
          | TupleSections :
              Bool
          | TypeApplications :
              Bool
          | TypeFamilies :
              Bool
          | TypeFamilyDependencies :
              Bool
          | TypeInType :
              Bool
          | TypeOperators :
              Bool
          | TypeSynonymInstances :
              Bool
          | UnboxedTuples :
              Bool
          | UndecidableInstances :
              Bool
          | UndecidableSuperClasses :
              Bool
          | UnicodeSyntax :
              Bool
          | UnliftedFFITypes :
              Bool
          | Unsafe :
              Bool
          | ViewPatterns :
              Bool
          | XmlSyntax :
              Bool
          >

in  let OS =
          < AIX :
              {}
          | Android :
              {}
          | DragonFly :
              {}
          | FreeBSD :
              {}
          | Ghcjs :
              {}
          | HPUX :
              {}
          | HaLVM :
              {}
          | Hurd :
              {}
          | IOS :
              {}
          | IRIX :
              {}
          | Linux :
              {}
          | NetBSD :
              {}
          | OSX :
              {}
          | OpenBSD :
              {}
          | OtherOS :
              { _1 : Text }
          | Solaris :
              {}
          | Windows :
              {}
          >

in  let Compiler =
          < GHC :
              {}
          | GHCJS :
              {}
          | HBC :
              {}
          | HaskellSuite :
              { _1 : Text }
          | Helium :
              {}
          | Hugs :
              {}
          | JHC :
              {}
          | LHC :
              {}
          | NHC :
              {}
          | OtherCompiler :
              { _1 : Text }
          | UHC :
              {}
          | YHC :
              {}
          >

in  let RepoKind =
          < RepoHead : {} | RepoKindUnknown : { _1 : Text } | RepoThis : {} >

in  let RepoType =
          < Bazaar :
              {}
          | CVS :
              {}
          | Darcs :
              {}
          | Git :
              {}
          | GnuArch :
              {}
          | Mercurial :
              {}
          | Monotone :
              {}
          | OtherRepoType :
              { _1 : Text }
          | SVN :
              {}
          >

in  let SourceRepo =
          { branch :
              Optional Text
          , kind :
              RepoKind
          , location :
              Optional Text
          , module :
              Optional Text
          , subdir :
              Optional Text
          , tag :
              Optional Text
          , type :
              Optional RepoType
          }

in  let Config =
          { os :
              OS → Bool
          , arch :
              Arch → Bool
          , flag :
              Text → Bool
          , impl :
              Compiler → VersionRange → Bool
          }

in  let BuildInfo =
          { autogen-modules :
              List Text
          , build-depends :
              List { bounds : VersionRange, package : Text }
          , build-tool-depends :
              List { component : Text, package : Text, version : VersionRange }
          , build-tools :
              List { exe : Text, version : VersionRange }
          , buildable :
              Bool
          , c-sources :
              List Text
          , cc-options :
              List Text
          , compiler-options :
              CompilerOptions
          , cpp-options :
              List Text
          , default-extensions :
              List Extension
          , default-language :
              Optional Language
          , extra-framework-dirs :
              List Text
          , extra-ghci-libraries :
              List Text
          , extra-lib-dirs :
              List Text
          , extra-libraries :
              List Text
          , frameworks :
              List Text
          , hs-source-dirs :
              List Text
          , include-dirs :
              List Text
          , includes :
              List Text
          , install-includes :
              List Text
          , js-sources :
              List Text
          , ld-options :
              List Text
          , mixins :
              List
              { package :
                  Text
              , renaming :
                  { provides :
                      List { rename : Text, to : Text }
                  , requires :
                      List { rename : Text, to : Text }
                  }
              }
          , other-extensions :
              List Extension
          , other-languages :
              List Language
          , other-modules :
              List Text
          , pkgconfig-depends :
              List { name : Text, version : VersionRange }
          , profiling-options :
              CompilerOptions
          , shared-options :
              CompilerOptions
          }

in  let TestSuite =
            BuildInfo
          ⩓ { type :
                < detailed :
                    { module : Text }
                | exitcode-stdio :
                    { main-is : Text }
                >
            }

in  let Benchmark = BuildInfo ⩓ { main-is : Text }

in  let ForeignLibrary =
            BuildInfo
          ⩓ { lib-version-info :
                Optional
                { age : Natural, current : Natural, revision : Natural }
            , lib-version-linux :
                Optional Version
            , mod-def-files :
                List Text
            , options :
                List < Standalone : {} >
            , type :
                < Shared : {} | Static : {} >
            }

in  let Library =
            BuildInfo
          ⩓ { exposed-modules :
                List Text
            , reexported-modules :
                List
                { name :
                    Text
                , original :
                    { name : Text, package : Optional Text }
                }
            , signatures :
                List Text
            }

in  { author :
        Text
    , benchmarks :
        List { benchmark : Config → Benchmark, name : Text }
    , bug-reports :
        Text
    , build-type :
        Optional BuildType
    , cabal-version :
        Version
    , category :
        Text
    , copyright :
        Text
    , custom-setup :
        Optional
        { setup-depends : List { bounds : VersionRange, package : Text } }
    , data-dir :
        Text
    , data-files :
        List Text
    , description :
        Text
    , executables :
        List
        { executable :
            Config → Benchmark ⩓ { scope : < Private : {} | Public : {} > }
        , name :
            Text
        }
    , extra-doc-files :
        List Text
    , extra-source-files :
        List Text
    , extra-tmp-files :
        List Text
    , flags :
        List { default : Bool, description : Text, manual : Bool, name : Text }
    , foreign-libraries :
        List { foreign-lib : Config → ForeignLibrary, name : Text }
    , homepage :
        Text
    , library :
        Optional (Config → Library)
    , license :
        License
    , license-files :
        List Text
    , maintainer :
        Text
    , name :
        Text
    , package-url :
        Text
    , source-repos :
        List SourceRepo
    , stability :
        Text
    , sub-libraries :
        List { library : Config → Library, name : Text }
    , synopsis :
        Text
    , test-suites :
        List { name : Text, test-suite : Config → TestSuite }
    , tested-with :
        List { compiler : Compiler, version : VersionRange }
    , version :
        Version
    , x-fields :
        List { _1 : Text, _2 : Text }
    }
ocharles commented 6 years ago

It's unfortunate that Executable no longer shows up as a let binding now, because it has common fields with Benchmark. I'll see what I can do about that.

quasicomputational commented 6 years ago

I had a stab at the Benchmark/Executable problem in #70, which should (if I've grokked the GitHub UI right) merge into this PR.