PostgREST / PostgREST/postgrest

Share common ghc options and other fields in `postgrest.cabal`

Open
#5,145 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

hygiene
Dominant language
Haskell
Stars
27.7k
Forks
1.2k
Avg merge
1d 9h
Merged PRs (30d)
54

Description

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:

https://github.com/PostgREST/postgrest/blob/ca4a6d9e9910a5503f6bb261c19017689ab821c7/postgrest.cabal#L176-L177

https://github.com/PostgREST/postgrest/blob/ca4a6d9e9910a5503f6bb261c19017689ab821c7/postgrest.cabal#L205-L207

Duplicated language extensions:

https://github.com/PostgREST/postgrest/blob/ca4a6d9e9910a5503f6bb261c19017689ab821c7/postgrest.cabal#L41-L44

https://github.com/PostgREST/postgrest/blob/ca4a6d9e9910a5503f6bb261c19017689ab821c7/postgrest.cabal#L221-L224

... and more.

Also discussed in https://github.com/PostgREST/postgrest/pull/5139#discussion_r3699864634

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in postgrest.cabal at the duplicated build fields, GHC options, and language extensions linked in the issue. Read the Cabal common stanza documentation and the discussion in pull request #5139 before deciding how to group the shared settings. Done means the relevant library, executable, and test-suite sections reuse common stanzas without duplicated options.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.