Skip to content

Share common ghc options and other fields in postgrest.cabal #5145

Description

@taimoorzaeem

Problem

Right now there is a lot of duplication in postgrest.cabal between different project components. This includes common build information, ghc-options, default language extensions and more.

Duplicated flags:

postgrest/postgrest.cabal

Lines 176 to 177 in ca4a6d9

ghc-options: -j -Werror -Wall -fwarn-identities
-fno-spec-constr -optP-Wno-nonportable-include-path

postgrest/postgrest.cabal

Lines 205 to 207 in ca4a6d9

ghc-options: -j -threaded -rtsopts "-with-rtsopts=-N -I0 -qg"
-O2 -Werror -Wall -fwarn-identities
-fno-spec-constr -optP-Wno-nonportable-include-path

Duplicated language extensions:

default-language: Haskell2010
default-extensions: OverloadedStrings
NoImplicitPrelude
NumericUnderscores

postgrest/postgrest.cabal

Lines 221 to 224 in ca4a6d9

default-extensions: OverloadedStrings
QuasiQuotes
NoImplicitPrelude
NumericUnderscores

... and more.

Also discussed in #5139 (comment)

Solution

We can use common stanzas to group these options and reuse in different places.

It would look something like:

common common-lang-edition
  default-language:   Haskell2010

common common-exts
  default-extensions: OverloadedStrings
                      NoImplicitPrelude
                      NumericUnderscores

common common-ghc-options
  ghc-options:        -j -Werror -Wall -fwarn-identities
                      -fno-spec-constr -optP-Wno-nonportable-include-path

.
.
.

library
  import:             common-lang-edition, common-exts, common-ghc-options
  ...

executable postgrest
  import:             common-lang-edition, common-exts, common-ghc-options
  ...

test-suite spec
  import:             common-lang-edition, common-exts, common-ghc-options
  default-extensions: QuasiQuotes
  ...

Notes

We should discuss how to group these effectively, the above is just an example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    hygienecleanup or refactoring

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions