From 5935a8cbe3a88f577f410c6ffac75b6f02f9a541 Mon Sep 17 00:00:00 2001 From: Joris Date: Mon, 1 May 2023 18:21:15 +0200 Subject: [PATCH 1/2] Various changes relating to repo maintenance --- .github/workflows/cabal.project.local.haskell | 7 + .github/workflows/haskell.yml | 80 ++++- .stylish-haskell.yaml | 276 +++++++++++++++++- CHANGELOG.md | 4 - CONTRIBUTING.md | 51 +++- RELEASE_PROCESS.md | 4 - diff-containers/changelog.d/scriv.ini | 13 - diff-containers/diff-containers.cabal | 108 ++++--- diff-containers/src/Data/Map/Diff/Strict.hs | 6 +- .../src/Data/Map/Diff/Strict/Internal.hs | 3 +- diff-containers/test/Main.hs | 3 +- .../test/Test/Data/Map/Diff/Strict.hs | 8 +- .../Data/FingerTree/RootMeasured/Strict.hs | 10 +- fingertree-rm/bench/Main.hs | 3 +- fingertree-rm/changelog.d/scriv.ini | 13 - fingertree-rm/fingertree-rm.cabal | 140 ++++----- .../Data/FingerTree/RootMeasured/Strict.hs | 6 +- fingertree-rm/test/Main.hs | 3 +- .../Data/FingerTree/RootMeasured/Strict.hs | 7 +- scripts/check-cabal.sh | 12 + scripts/format-cabal.sh | 5 + simple-semigroupoids/changelog.d/scriv.ini | 13 - .../simple-semigroupoids.cabal | 105 +++---- .../src/Data/Semigroupoid/Simple/Auto.hs | 4 +- .../src/Data/Semigroupoid/Simple/Laws.hs | 3 - simple-semigroupoids/test/Main.hs | 5 +- .../test/Test/Data/Semigroupoid/Simple.hs | 8 +- 27 files changed, 581 insertions(+), 319 deletions(-) create mode 100644 .github/workflows/cabal.project.local.haskell delete mode 100644 CHANGELOG.md delete mode 100644 RELEASE_PROCESS.md delete mode 100644 diff-containers/changelog.d/scriv.ini delete mode 100644 fingertree-rm/changelog.d/scriv.ini create mode 100755 scripts/check-cabal.sh create mode 100755 scripts/format-cabal.sh delete mode 100644 simple-semigroupoids/changelog.d/scriv.ini diff --git a/.github/workflows/cabal.project.local.haskell b/.github/workflows/cabal.project.local.haskell new file mode 100644 index 0000000..f834144 --- /dev/null +++ b/.github/workflows/cabal.project.local.haskell @@ -0,0 +1,7 @@ +ignore-project: False + +tests: True +benchmarks: True + +program-options + ghc-options: -Werror \ No newline at end of file diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 2a52b6b..6c881b5 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -16,16 +16,11 @@ jobs: strategy: fail-fast: false matrix: - ghc: ["8.10.7", "9.2.5"] + ghc: ["8.10.7", "9.2.7"] cabal: ["3.8.1.0"] os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - name: Workaround runner image issue - if: runner.os == 'Linux' - # https://github.com/actions/runner-images/issues/7061 - run: sudo chown -R $USER /usr/local/.ghcup - - name: Checkout repository uses: actions/checkout@v3 @@ -37,6 +32,10 @@ jobs: cabal-version: ${{ matrix.cabal }} cabal-update: false + - name: "Configure cabal.project.local" + run: | + cp .github/workflows/cabal.project.local.haskell cabal.project.local + - name: Cabal update run: cabal update @@ -67,21 +66,18 @@ jobs: - name: Run tests run: cabal test all + # Check formatting for Haskell files stylish-haskell: runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - ghc: ["9.2.5"] + ghc: ["9.2.7"] cabal: ["3.8.1.0"] os: [ubuntu-latest] steps: - - name: Workaround runner image issue - # https://github.com/actions/runner-images/issues/7061 - run: sudo chown -R $USER /usr/local/.ghcup - - name: Checkout repository uses: actions/checkout@v3 @@ -128,4 +124,64 @@ jobs: - name: Run stylish-haskell run: | ./scripts/format-stylish.sh -p . -d - git diff --exit-code \ No newline at end of file + git diff --exit-code + + # Check formatting for cabal files + cabal-fmt: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + matrix: + ghc: ["9.2.7"] + cabal: ["3.8.1.0"] + os: [ubuntu-latest] + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Install system dependencies (apt-get) + run: | + sudo apt-get update + sudo apt-get -y install fd-find + + - name: Setup Haskell + id: setup-haskell + uses: haskell/actions/setup@v2 + with: + ghc-version: ${{ matrix.ghc }} + cabal-version: ${{ matrix.cabal }} + cabal-update: false + + - name: Cabal update + run: cabal update + + - name: Setup cabal bin path + run: echo "$HOME/.cabal/bin" >> $GITHUB_PATH + + - name: Cache cabal store + uses: actions/cache@v3 + env: + cache-name: cache-cabal-cabal-fmt + with: + path: ${{ steps.setup-haskell.outputs.cabal-store }} + key: ${{ runner.os }}-${{ matrix.ghc }}-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} + restore-keys: | + ${{ runner.os }}-${{ matrix.ghc }}-cabal-fmt-${{ env.cache-name }}- + ${{ runner.os }}-${{ matrix.ghc }}-cabal-fmt + ${{ runner.os }}-${{ matrix.ghc }} + ${{ runner.os }}- + + - name: Install cabal-fmt + run: cabal install cabal-fmt --constraint 'cabal-fmt == 0.1.6' + + - name: Record cabal-fmt version + run: | + which cabal-fmt + cabal-fmt --version + + - name: Run cabal-fmt + run: | + ./scripts/format-cabal.sh + git diff --exit-code diff --git a/.stylish-haskell.yaml b/.stylish-haskell.yaml index 3c7daa0..726da23 100644 --- a/.stylish-haskell.yaml +++ b/.stylish-haskell.yaml @@ -1,3 +1,5 @@ +# Copied from https://github.com/input-output-hk/ouroboros-consensus/blob/e19a58d078b882e5180d9ef591a1f4e9a1987fe0/.stylish-haskell.yaml +# # Stylish-haskell configuration file used for the Consensus layer # It's based on default config provided by `stylish-haskell --defaults` but has some changes # ================================== @@ -15,16 +17,22 @@ steps: # # language extensions using some other method than pragmas. Default: # # true. # add_language_pragma: true + + # Format module header + # + # Currently, this option is not configurable and will format all exports and + # module declarations to minimize diffs + # - module_header: # # How many spaces use for indentation in the module header. - indent: 2 + indent: 2 # # # Should export lists be sorted? Sorting is only performed within the # # export section, as delineated by Haddock comments. - sort: true + sort: true # # # See `separate_lists` for the `imports` step. - separate_lists: true + separate_lists: true # # # When to break the "where". # # Possible values: @@ -34,21 +42,84 @@ steps: # # determined by the `columns` setting. Not applicable when the export # # list contains comments as newlines will be required. # # - always: always break before the "where". - break_where: single + break_where: single + # # # Where to put open bracket # # Possible values: # # - same_line: put open bracket on the same line as the module name, before the # # comment of the module # # - next_line: put open bracket on the next line, after module comment - open_bracket: same_line + open_bracket: same_line + + # Format record definitions. This is disabled by default. + # + # You can control the layout of record fields. The only rules that can't be configured + # are these: + # + # - "|" is always aligned with "=" + # - "," in fields is always aligned with "{" + # - "}" is likewise always aligned with "{" + # + # - records: + # # How to format equals sign between type constructor and data constructor. + # # Possible values: + # # - "same_line" -- leave "=" AND data constructor on the same line as the type constructor. + # # - "indent N" -- insert a new line and N spaces from the beginning of the next line. + # equals: "indent 2" + # + # # How to format first field of each record constructor. + # # Possible values: + # # - "same_line" -- "{" and first field goes on the same line as the data constructor. + # # - "indent N" -- insert a new line and N spaces from the beginning of the data constructor + # first_field: "indent 2" + # + # # How many spaces to insert between the column with "," and the beginning of the comment in the next line. + # field_comment: 2 + # + # # How many spaces to insert before "deriving" clause. Deriving clauses are always on separate lines. + # deriving: 2 + # + # # How many spaces to insert before "via" clause counted from indentation of deriving clause + # # Possible values: + # # - "same_line" -- "via" part goes on the same line as "deriving" keyword. + # # - "indent N" -- insert a new line and N spaces from the beginning of "deriving" keyword. + # via: "indent 2" + # + # # Sort typeclass names in the "deriving" list alphabetically. + # sort_deriving: true + # + # # Whether or not to break enums onto several lines + # # + # # Default: false + # break_enums: false + # + # # Whether or not to break single constructor data types before `=` sign + # # + # # Default: true + # break_single_constructors: true + # + # # Whether or not to curry constraints on function. + # # + # # E.g: @allValues :: Enum a => Bounded a => Proxy a -> [a]@ + # # + # # Instead of @allValues :: (Enum a, Bounded a) => Proxy a -> [a]@ + # # + # # Default: false + # curried_context: false # Align the right hand side of some elements. This is quite conservative # and only applies to statements where each element occupies a single # line. + # Possible values: + # - always - Always align statements. + # - adjacent - Align statements that are on adjacent lines in groups. + # - never - Never align statements. + # All default to always. - simple_align: - cases: true - top_level_patterns: true - records: true + cases: always + top_level_patterns: always + records: always + multi_way_if: always # Import cleanup - imports: @@ -83,11 +154,28 @@ steps: # > import qualified Data.List as List (concat, foldl, foldr, head, # > init, last, length) # + # - with_module_name: Import list is aligned `list_padding` spaces after + # the module name. + # + # > import qualified Data.List as List (concat, foldl, foldr, head, + # init, last, length) + # + # This is mainly intended for use with `pad_module_names: false`. + # + # > import qualified Data.List as List (concat, foldl, foldr, head, + # init, last, length, scanl, scanr, take, drop, + # sort, nub) + # # - new_line: Import list starts always on new line. # # > import qualified Data.List as List # > (concat, foldl, foldr, head, init, last, length) # + # - repeat: Repeat the module name to align the import list. + # + # > import qualified Data.List as List (concat, foldl, foldr, head) + # > import qualified Data.List as List (init, last, length) + # # Default: after_alias list_align: with_module_name @@ -156,6 +244,8 @@ steps: # # - module_name: align under start of module name. # Useful for 'file' and 'group' align settings. + # + # Default: 4 list_padding: 4 # Separate lists option affects formatting of import list for type @@ -191,6 +281,127 @@ steps: # Default: false space_surround: false + # Post qualify option moves any qualifies found in import declarations + # to the end of the declaration. This also adjust padding for any + # unqualified import declarations. + # + # - true: Qualified as is moved to the end of the + # declaration. + # + # > import Data.Bar + # > import Data.Foo qualified as F + # + # - false: Qualified remains in the default location and unqualified + # imports are padded to align with qualified imports. + # + # > import Data.Bar + # > import qualified Data.Foo as F + # + # Default: false + post_qualify: false + + # Automatically group imports based on their module names, with + # a blank line separating each group. Groups are ordered in + # alphabetical order. + # + # By default, this groups by the first part of each module's + # name (Control.* will be grouped together, Data.*... etc), but + # this can be configured with the group_patterns setting. + # + # When enabled, this rewrites existing blank lines and groups. + # + # - true: Group imports by the first part of the module name. + # + # > import Control.Applicative + # > import Control.Monad + # > import Control.Monad.MonadError + # > + # > import Data.Functor + # + # - false: Keep import groups as-is (still sorting and + # formatting the imports within each group) + # + # > import Control.Monad + # > import Data.Functor + # > + # > import Control.Applicative + # > import Control.Monad.MonadError + # + # Default: false + group_imports: true + + # A list of rules specifying how to group modules and how to + # order the groups. + # + # Each rule has a match field; the rule only applies to module + # names matched by this pattern. Patterns are POSIX extended + # regular expressions; see the documentation of Text.Regex.TDFA + # for details: + # https://hackage.haskell.org/package/regex-tdfa-1.3.1.2/docs/Text-Regex-TDFA.html + # + # Rules are processed in order, so only the *first* rule that + # matches a specific module will apply. Any module names that do + # not match a single rule will be put into a single group at the + # end of the import block. + # + # Example: group MyApp modules first, with everything else in + # one group at the end. + # + # group_rules: + # - match: "^MyApp\\>" + # + # > import MyApp + # > import MyApp.Foo + # > + # > import Control.Monad + # > import MyApps + # > import Test.MyApp + # + # A rule can also optionally have a sub_group pattern. Imports + # that match the rule will be broken up into further groups by + # the part of the module name matched by the sub_group pattern. + # + # Example: group MyApp modules first, then everything else + # sub-grouped by the first part of the module name. + # + # group_rules: + # - match: "^MyApp\\>" + # - match: "." + # sub_group: "^[^.]+" + # + # > import MyApp + # > import MyApp.Foo + # > + # > import Control.Applicative + # > import Control.Monad + # > + # > import Data.Map + # + # A pattern only needs to match part of the module name, which + # could be in the middle. You can use ^pattern to anchor to the + # beginning of the module name, pattern$ to anchor to the end + # and ^pattern$ to force a full match. Example: + # + # - "Test\\." would match "Test.Foo" and "Foo.Test.Lib" + # - "^Test\\." would match "Test.Foo" but not "Foo.Test.Lib" + # - "\\.Test$" would match "Foo.Test" but not "Foo.Test.Lib" + # - "^Test$" would *only* match "Test" + # + # You can use \\< and \\> to anchor against the beginning and + # end of words, respectively. For example: + # + # - "^Test\\." would match "Test.Foo" but not "Test" or "Tests" + # - "^Test\\>" would match "Test.Foo" and "Test", but not + # "Tests" + # + # The default is a single rule that matches everything and + # sub-groups based on the first component of the module name. + # + # Default: [{ "match" : ".*", "sub_group": "^[^.]+" }] + group_rules: + - match: "." + + # Language pragmas - language_pragmas: # We can generate different styles of language pragma lists. @@ -200,15 +411,32 @@ steps: # - compact: A more compact style. # # - compact_line: Similar to compact, but wrap each line with - # `{-#LANGUAGE #-}'. + # `{-# LANGUAGE #-}'. + # + # - vertical_compact: Similar to vertical, but use only one language pragma. # # Default: vertical. style: vertical + # Align affects alignment of closing pragma brackets. + # + # - true: Brackets are aligned in same column. + # + # - false: Brackets are not aligned together. There is only one space + # between actual import and closing bracket. + # + # Default: true + align: true + # stylish-haskell can detect redundancy of some language pragmas. If this # is set to true, it will remove those redundant pragmas. Default: true. remove_redundant: true + # Language prefix to be used for pragma declaration, this allows you to + # use other options non case-sensitive like "language" or "Language". + # If a non correct String is provided, it will default to: LANGUAGE. + language_prefix: LANGUAGE + # Replace tabs by spaces. This is disabled by default. # - tabs: # # Number of spaces to use for each tab. Default: 8, as specified by the @@ -218,8 +446,17 @@ steps: # Remove trailing whitespace - trailing_whitespace: {} + # Squash multiple spaces between the left and right hand sides of some + # elements into single spaces. Basically, this undoes the effect of + # simple_align but is a bit less conservative. + # - squash: {} + # A common setting is the number of columns (parts of) code will be wrapped -# to. Different steps take this into account. Default: 80. +# to. Different steps take this into account. +# +# Set this to null to disable all line wrapping. +# +# Default: 80. columns: 80 # By default, line endings are converted according to the OS. You can override @@ -234,13 +471,11 @@ columns: 80 # Default: native. newline: native -# These syntax-affecting language extensions are enabled so that -# stylish-haskell wouldn't fail with parsing errors when processing files -# in projects that have those extensions enabled in the .cabal file -# rather than locally. +# Sometimes, language extensions are specified in a cabal file or from the +# command line instead of using language pragmas in the file. stylish-haskell +# needs to be aware of these, so it can parse the file correctly. # -# To my best knowledge, no harm should result from enabling an extension -# that isn't actually used in the file/project. —@neongreen +# No language extensions are enabled by default. language_extensions: - BangPatterns - ConstraintKinds @@ -269,3 +504,12 @@ language_extensions: - TypeFamilies - ViewPatterns - ExplicitNamespaces + +# Attempt to find the cabal file in ancestors of the current directory, and +# parse options (currently only language extensions) from that. +# +# Default: true +# +# We run stylish from the root of the repo which is a project so this flag +# doesn't apply +cabal: false diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 644e083..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,4 +0,0 @@ -See the [consensus changelog file in the `ouroboros-network` -repository](https://github.com/input-output-hk/ouroboros-network/blob/master/Consensus-CHANGELOG.md). -Note that we do not do any bundling of packages: each package has its own -changelog, and each can be released separately. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5420444..74c5b50 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,5 +1,50 @@ # Contributing -See [the contributing file in the `ouroboros-network` repository]( -https://github.com/input-output-hk/ouroboros-network/blob/master/CONTRIBUTING.md). -We follow consensus guidelines where consensus and network diverge. \ No newline at end of file +## Building + +The project is built using `ghc` and `cabal`, and does not require any external +dependencies. + +``` +cabal update +cabal build all +``` + +## Testing + +Tests are run using `cabal`. + +``` +cabal build all +cabal test all +``` + +## Code style + +There is no strict code style, but try to keep the code style consistent +throughout the repository and favour readability. Code should be well-documented and well-tested. + +## Formatting + +We use `stylish-haskell` to format Haskell files, and we use `cabal-fmt` to +format `*.cabal` files. We also use `cabal check` to sanity check our cabal files. See the helpful scripts in the [scripts folder](./scripts/), and the [`stylish-haskell` configuration file](./.stylish-haskell.yaml). + +## Pull requests + +The following are requirements for merging a PR into `main`: +* Each commit should be small and should preferably address one thing. Commit messages should be useful. +* Document and test your changes. +* The PR should have a useful description, and it should link issues that it + resolves. +* Changes introduced by the PR should be recorded in the relevant changelog + files. +* PRs should not bundle many unrelated changes. +* PRs should be approved by at least 1 developer. +* The PR should pass all CI checks. + +## Releases + +Releases follow the [Haskell Package Versioning Policy](https://pvp.haskell.org/). We use version numbers consisting of 4 parts, like `A.B.C.D`. +* `A.B` is the *major* version number. A bump indicates a breaking change. +* `C` is the *minor* version number. A bump indicates a non-breaking change. +* `D` is the *patch* version number. A bump indicates a small, non-breaking patch. \ No newline at end of file diff --git a/RELEASE_PROCESS.md b/RELEASE_PROCESS.md deleted file mode 100644 index 012a2e5..0000000 --- a/RELEASE_PROCESS.md +++ /dev/null @@ -1,4 +0,0 @@ -See the [consensus release process file in the `ouroboros-network` -repository](https://github.com/input-output-hk/ouroboros-network/blob/master/ouroboros-consensus/docs/ReleaseProcess.md). -Note that we do not do any bundling of packages: each package has its own -changelog, and each can be released separately. \ No newline at end of file diff --git a/diff-containers/changelog.d/scriv.ini b/diff-containers/changelog.d/scriv.ini deleted file mode 100644 index 91fec42..0000000 --- a/diff-containers/changelog.d/scriv.ini +++ /dev/null @@ -1,13 +0,0 @@ -[scriv] -format = md -# insert_marker = Changelog entries -md_header_level = 2 -version = literal: ../diff-containers/diff-containers.cabal: version -categories = Patch, Non-Breaking, Breaking -end_marker = scriv-end-here -fragment_directory = ../diff-containers/changelog.d -ghrel_template = {{body}} -main_branches = master, main, develop -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = ../diff-containers/CHANGELOG.${config:format} -skip_fragments = README.* \ No newline at end of file diff --git a/diff-containers/diff-containers.cabal b/diff-containers/diff-containers.cabal index 9aa95bd..ccb3089 100644 --- a/diff-containers/diff-containers.cabal +++ b/diff-containers/diff-containers.cabal @@ -1,70 +1,64 @@ -cabal-version: 3.0 -name: diff-containers -version: 0.1.0.0 -synopsis: Diffs for containers +cabal-version: 3.0 +name: diff-containers +version: 0.1.0.0 +synopsis: Diffs for containers + -- description: -license: Apache-2.0 +license: Apache-2.0 license-files: LICENSE NOTICE -copyright: 2022 Input Output (Hong Kong) Ltd. -author: Joris Dral -maintainer: operations@iohk.io -category: Data Structures -build-type: Simple -tested-with: GHC == { 8.10.7, 9.2.5 } +copyright: 2022-2023 Input Output (Hong Kong) Ltd. +author: Joris Dral +maintainer: operations@iohk.io +category: Data Structures +build-type: Simple +tested-with: GHC ==8.10 || ==9.2 library - default-language: Haskell2010 - hs-source-dirs: src - - exposed-modules: Data.Map.Diff.Strict - Data.Map.Diff.Strict.Internal - other-modules: Data.Sequence.NonEmpty.Extra + default-language: Haskell2010 + hs-source-dirs: src + exposed-modules: + Data.Map.Diff.Strict + Data.Map.Diff.Strict.Internal - build-depends: base >=4.9 && <4.17 - , containers - , groups - , nonempty-containers - , nothunks + other-modules: Data.Sequence.NonEmpty.Extra + build-depends: + , base >=4.9 && <4.17 + , containers + , groups + , nonempty-containers + , nothunks - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists -Wunused-packages + -Wno-unticked-promoted-constructors test-suite test - type: exitcode-stdio-1.0 - default-language: Haskell2010 - hs-source-dirs: test - main-is: Main.hs - - other-modules: Test.Data.Map.Diff.Strict - Test.Util + type: exitcode-stdio-1.0 + default-language: Haskell2010 + hs-source-dirs: test + main-is: Main.hs + other-modules: + Test.Data.Map.Diff.Strict + Test.Util - build-depends: base >=4.9 && <4.17 - , containers - , diff-containers - , groups - , nonempty-containers - , QuickCheck - , simple-semigroupoids - , tasty - , tasty-quickcheck + build-depends: + , base >=4.9 && <4.17 + , containers + , diff-containers + , groups + , nonempty-containers + , QuickCheck + , simple-semigroupoids + , tasty + , tasty-quickcheck - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors - -fno-ignore-asserts + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists -Wunused-packages + -Wno-unticked-promoted-constructors -fno-ignore-asserts diff --git a/diff-containers/src/Data/Map/Diff/Strict.hs b/diff-containers/src/Data/Map/Diff/Strict.hs index bbffe85..8c6b21d 100644 --- a/diff-containers/src/Data/Map/Diff/Strict.hs +++ b/diff-containers/src/Data/Map/Diff/Strict.hs @@ -56,9 +56,7 @@ module Data.Map.Diff.Strict ( , filterOnlyKey ) where -import Prelude hiding (null) - import Data.Group (Group) -import Data.Map.Strict (Map) - import Data.Map.Diff.Strict.Internal +import Data.Map.Strict (Map) +import Prelude hiding (null) diff --git a/diff-containers/src/Data/Map/Diff/Strict/Internal.hs b/diff-containers/src/Data/Map/Diff/Strict/Internal.hs index 5edd931..f83e65d 100644 --- a/diff-containers/src/Data/Map/Diff/Strict/Internal.hs +++ b/diff-containers/src/Data/Map/Diff/Strict/Internal.hs @@ -63,8 +63,6 @@ module Data.Map.Diff.Strict.Internal ( , filterOnlyKey ) where -import Prelude hiding (last, length, null, splitAt) - import Control.Monad (void) import Data.Bifunctor import Data.Either (fromRight) @@ -81,6 +79,7 @@ import Data.Set (Set) import qualified Data.Set as Set import GHC.Generics (Generic) import NoThunks.Class (NoThunks (..)) +import Prelude hiding (last, length, null, splitAt) {------------------------------------------------------------------------------ Types diff --git a/diff-containers/test/Main.hs b/diff-containers/test/Main.hs index b515e6b..8a967ac 100644 --- a/diff-containers/test/Main.hs +++ b/diff-containers/test/Main.hs @@ -1,8 +1,7 @@ module Main (main) where -import Test.Tasty - import qualified Test.Data.Map.Diff.Strict +import Test.Tasty main :: IO () main = defaultMain tests diff --git a/diff-containers/test/Test/Data/Map/Diff/Strict.hs b/diff-containers/test/Test/Data/Map/Diff/Strict.hs index 2e67d8a..29c9ee2 100644 --- a/diff-containers/test/Test/Data/Map/Diff/Strict.hs +++ b/diff-containers/test/Test/Data/Map/Diff/Strict.hs @@ -11,19 +11,15 @@ module Test.Data.Map.Diff.Strict (tests) where import Data.Either import Data.Foldable import Data.Group (Group (..)) +import Data.Map.Diff.Strict.Internal hiding (null) import Data.Map.Strict (Map) import Data.Maybe import Data.Proxy (Proxy (Proxy)) +import Data.Semigroupoid.Simple.Laws import Data.Sequence.NonEmpty (NESeq (..)) import qualified Data.Sequence.NonEmpty as NESeq - import Test.Tasty (TestTree, localOption, testGroup) import Test.Tasty.QuickCheck hiding (Negative, Positive) - -import Data.Map.Diff.Strict.Internal hiding (null) - -import Data.Semigroupoid.Simple.Laws - import Test.Util -- | Tests for "Data.Map.Diff.Strict". diff --git a/fingertree-rm/bench/Bench/Data/FingerTree/RootMeasured/Strict.hs b/fingertree-rm/bench/Bench/Data/FingerTree/RootMeasured/Strict.hs index 3ea5785..01ea98f 100644 --- a/fingertree-rm/bench/Bench/Data/FingerTree/RootMeasured/Strict.hs +++ b/fingertree-rm/bench/Bench/Data/FingerTree/RootMeasured/Strict.hs @@ -13,19 +13,17 @@ module Bench.Data.FingerTree.RootMeasured.Strict (benchmarks) where import Control.Arrow import Control.DeepSeq (NFData (..)) import Data.Bifunctor +import qualified Data.FingerTree as FT +import Data.FingerTree.RootMeasured.Strict +import qualified Data.FingerTree.Strict as SFT import Data.Foldable import Data.Group import Data.Monoid -import Text.Printf - import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.Bench import Test.Tasty.QuickCheck - -import qualified Data.FingerTree as FT -import Data.FingerTree.RootMeasured.Strict -import qualified Data.FingerTree.Strict as SFT +import Text.Printf {------------------------------------------------------------------------------- Main benchmark tree diff --git a/fingertree-rm/bench/Main.hs b/fingertree-rm/bench/Main.hs index 424b752..48e6599 100644 --- a/fingertree-rm/bench/Main.hs +++ b/fingertree-rm/bench/Main.hs @@ -1,8 +1,7 @@ module Main (main) where -import Test.Tasty.Bench - import Bench.Data.FingerTree.RootMeasured.Strict (benchmarks) +import Test.Tasty.Bench main :: IO () main = defaultMain [ diff --git a/fingertree-rm/changelog.d/scriv.ini b/fingertree-rm/changelog.d/scriv.ini deleted file mode 100644 index e93ebf3..0000000 --- a/fingertree-rm/changelog.d/scriv.ini +++ /dev/null @@ -1,13 +0,0 @@ -[scriv] -format = md -# insert_marker = Changelog entries -md_header_level = 2 -version = literal: ../fingertree-rm/fingertree-rm.cabal: version -categories = Patch, Non-Breaking, Breaking -end_marker = scriv-end-here -fragment_directory = ../fingertree-rm/changelog.d -ghrel_template = {{body}} -main_branches = master, main, develop -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = ../fingertree-rm/CHANGELOG.${config:format} -skip_fragments = README.* \ No newline at end of file diff --git a/fingertree-rm/fingertree-rm.cabal b/fingertree-rm/fingertree-rm.cabal index d9b5350..4058222 100644 --- a/fingertree-rm/fingertree-rm.cabal +++ b/fingertree-rm/fingertree-rm.cabal @@ -1,92 +1,76 @@ -cabal-version: 3.0 -name: fingertree-rm -version: 0.1.0.0 -synopsis: Finger-trees with root measures +cabal-version: 3.0 +name: fingertree-rm +version: 0.1.0.0 +synopsis: Finger-trees with root measures + -- description: -license: Apache-2.0 +license: Apache-2.0 license-files: LICENSE NOTICE -copyright: 2022 Input Output (Hong Kong) Ltd. -author: Joris Dral -maintainer: operations@iohk.io -category: Data Structures -build-type: Simple -tested-with: GHC == { 8.10.7, 9.2.5 } +copyright: 2022-2023 Input Output (Hong Kong) Ltd. +author: Joris Dral +maintainer: operations@iohk.io +category: Data Structures +build-type: Simple +tested-with: GHC ==8.10 || ==9.2 library - default-language: Haskell2010 - hs-source-dirs: src - - exposed-modules: Data.FingerTree.RootMeasured.Strict + default-language: Haskell2010 + hs-source-dirs: src + exposed-modules: Data.FingerTree.RootMeasured.Strict + build-depends: + , base >=4.9 && <4.17 + , cardano-strict-containers + , groups + , nothunks - build-depends: base >=4.9 && <4.17 - , cardano-strict-containers - , groups - , nothunks - - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists -Wunused-packages + -Wno-unticked-promoted-constructors test-suite test - type: exitcode-stdio-1.0 - default-language: Haskell2010 - hs-source-dirs: test - main-is: Main.hs - - other-modules: Test.Data.FingerTree.RootMeasured.Strict + type: exitcode-stdio-1.0 + default-language: Haskell2010 + hs-source-dirs: test + main-is: Main.hs + other-modules: Test.Data.FingerTree.RootMeasured.Strict + build-depends: + , base >=4.9 && <4.17 + , fingertree-rm + , simple-semigroupoids + , tasty + , tasty-quickcheck - build-depends: base >=4.9 && <4.17 - , fingertree-rm - , simple-semigroupoids - , tasty - , tasty-quickcheck - - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors - -fno-ignore-asserts + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists + -Wno-unticked-promoted-constructors -fno-ignore-asserts benchmark bench - type: exitcode-stdio-1.0 - default-language: Haskell2010 - hs-source-dirs: bench - main-is: Main.hs - - other-modules: Bench.Data.FingerTree.RootMeasured.Strict - - build-depends: base >=4.9 && <4.17 - , cardano-strict-containers - , deepseq - , fingertree - , fingertree-rm - , groups - , QuickCheck - , tasty - , tasty-bench - , tasty-quickcheck + type: exitcode-stdio-1.0 + default-language: Haskell2010 + hs-source-dirs: bench + main-is: Main.hs + other-modules: Bench.Data.FingerTree.RootMeasured.Strict + build-depends: + , base >=4.9 && <4.17 + , cardano-strict-containers + , deepseq + , fingertree + , fingertree-rm + , groups + , QuickCheck + , tasty + , tasty-bench + , tasty-quickcheck - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors - -fno-ignore-asserts + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists -Wunused-packages + -Wno-unticked-promoted-constructors -fno-ignore-asserts diff --git a/fingertree-rm/src/Data/FingerTree/RootMeasured/Strict.hs b/fingertree-rm/src/Data/FingerTree/RootMeasured/Strict.hs index 644f81c..6b3faa8 100644 --- a/fingertree-rm/src/Data/FingerTree/RootMeasured/Strict.hs +++ b/fingertree-rm/src/Data/FingerTree/RootMeasured/Strict.hs @@ -28,15 +28,13 @@ module Data.FingerTree.RootMeasured.Strict ( , fmap'' ) where +import Data.FingerTree.Strict (Measured) +import qualified Data.FingerTree.Strict as FT import Data.Foldable import Data.Group import GHC.Generics (Generic) - import NoThunks.Class (NoThunks (..), noThunksInValues) -import Data.FingerTree.Strict (Measured) -import qualified Data.FingerTree.Strict as FT - {------------------------------------------------------------------------------- Strict finger trees with root measures -------------------------------------------------------------------------------} diff --git a/fingertree-rm/test/Main.hs b/fingertree-rm/test/Main.hs index 09fb973..e40fa3d 100644 --- a/fingertree-rm/test/Main.hs +++ b/fingertree-rm/test/Main.hs @@ -1,8 +1,7 @@ module Main (main) where -import Test.Tasty - import qualified Test.Data.FingerTree.RootMeasured.Strict +import Test.Tasty main :: IO () main = defaultMain tests diff --git a/fingertree-rm/test/Test/Data/FingerTree/RootMeasured/Strict.hs b/fingertree-rm/test/Test/Data/FingerTree/RootMeasured/Strict.hs index 8369070..add3d57 100644 --- a/fingertree-rm/test/Test/Data/FingerTree/RootMeasured/Strict.hs +++ b/fingertree-rm/test/Test/Data/FingerTree/RootMeasured/Strict.hs @@ -12,17 +12,14 @@ module Test.Data.FingerTree.RootMeasured.Strict ( , splitProp ) where +import Data.FingerTree.RootMeasured.Strict import Data.Foldable (toList) import Data.Monoid (Sum (..)) import Data.Proxy - +import Data.Semigroupoid.Simple.Laws (testGroupWithProxy) import Test.Tasty import Test.Tasty.QuickCheck -import Data.FingerTree.RootMeasured.Strict -import Data.Semigroupoid.Simple.Laws (testGroupWithProxy) - - tests :: TestTree tests = testGroup "Data.FingerTree.TopMeasured.Strict" [ testGroupWithProxy (Proxy @T) [ diff --git a/scripts/check-cabal.sh b/scripts/check-cabal.sh new file mode 100755 index 0000000..c80c7d4 --- /dev/null +++ b/scripts/check-cabal.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -euo pipefail + +for x in $(find . -name '*.cabal' | grep -v dist-newstyle | cut -c 3-); do + ( + d=$(dirname $x) + echo "== $d ==" + cd $d + cabal check + ) +done \ No newline at end of file diff --git a/scripts/format-cabal.sh b/scripts/format-cabal.sh new file mode 100755 index 0000000..5a843cf --- /dev/null +++ b/scripts/format-cabal.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -euo pipefail + +fdfind -p . -e cabal -x cabal-fmt -i \ No newline at end of file diff --git a/simple-semigroupoids/changelog.d/scriv.ini b/simple-semigroupoids/changelog.d/scriv.ini deleted file mode 100644 index 439c657..0000000 --- a/simple-semigroupoids/changelog.d/scriv.ini +++ /dev/null @@ -1,13 +0,0 @@ -[scriv] -format = md -# insert_marker = Changelog entries -md_header_level = 2 -version = literal: ../simple-semigroupoids/simple-semigroupoids.cabal: version -categories = Patch, Non-Breaking, Breaking -end_marker = scriv-end-here -fragment_directory = ../simple-semigroupoids/changelog.d -ghrel_template = {{body}} -main_branches = master, main, develop -new_fragment_template = file: new_fragment.${config:format}.j2 -output_file = ../simple-semigroupoids/CHANGELOG.${config:format} -skip_fragments = README.* \ No newline at end of file diff --git a/simple-semigroupoids/simple-semigroupoids.cabal b/simple-semigroupoids/simple-semigroupoids.cabal index 164f9ab..ea64131 100644 --- a/simple-semigroupoids/simple-semigroupoids.cabal +++ b/simple-semigroupoids/simple-semigroupoids.cabal @@ -1,65 +1,56 @@ -cabal-version: 3.0 -name: simple-semigroupoids -version: 0.1.0.0 -synopsis: Groupoid-like structures and testing utilities +cabal-version: 3.0 +name: simple-semigroupoids +version: 0.1.0.0 +synopsis: Groupoid-like structures and testing utilities + -- description: -license: Apache-2.0 +license: Apache-2.0 license-files: LICENSE NOTICE -copyright: 2022 Input Output (Hong Kong) Ltd. -author: Joris Dral -maintainer: operations@iohk.io -category: Control, Testing -build-type: Simple -tested-with: GHC == { 8.10.7, 9.2.5 } - -library - default-language: Haskell2010 - hs-source-dirs: src - - exposed-modules: Data.Semigroupoid.Simple - Data.Semigroupoid.Simple.Auto - Data.Semigroupoid.Simple.Laws - build-depends: base >=4.9 && <4.17 - , groups - , QuickCheck - , tasty - , tasty-quickcheck +copyright: 2022-2023 Input Output (Hong Kong) Ltd. +author: Joris Dral +maintainer: operations@iohk.io +category: Control, Testing +build-type: Simple +tested-with: GHC ==8.10 || ==9.2 - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors +library + default-language: Haskell2010 + hs-source-dirs: src + exposed-modules: + Data.Semigroupoid.Simple + Data.Semigroupoid.Simple.Auto + Data.Semigroupoid.Simple.Laws + + build-depends: + , base >=4.9 && <4.17 + , groups + , QuickCheck + , tasty + , tasty-quickcheck + + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists -Wunused-packages + -Wno-unticked-promoted-constructors test-suite test - type: exitcode-stdio-1.0 - default-language: Haskell2010 - hs-source-dirs: test - main-is: Main.hs - - other-modules: Test.Data.Semigroupoid.Simple - - build-depends: base >=4.9 && <4.17 - , groups - , QuickCheck - , simple-semigroupoids - , tasty - , tasty-quickcheck - - ghc-options: -Wall - -Wcompat - -Wincomplete-uni-patterns - -Wincomplete-record-updates - -Wpartial-fields - -Widentities - -Wredundant-constraints - -Wmissing-export-lists - -Wno-unticked-promoted-constructors - -fno-ignore-asserts + type: exitcode-stdio-1.0 + default-language: Haskell2010 + hs-source-dirs: test + main-is: Main.hs + other-modules: Test.Data.Semigroupoid.Simple + build-depends: + , base >=4.9 && <4.17 + , simple-semigroupoids + , tasty + , tasty-quickcheck + + ghc-options: + -Wall -Wcompat -Wincomplete-uni-patterns + -Wincomplete-record-updates -Wpartial-fields -Widentities + -Wredundant-constraints -Wmissing-export-lists -Wunused-packages + -Wno-unticked-promoted-constructors -fno-ignore-asserts diff --git a/simple-semigroupoids/src/Data/Semigroupoid/Simple/Auto.hs b/simple-semigroupoids/src/Data/Semigroupoid/Simple/Auto.hs index 977d6e0..3ff80cc 100644 --- a/simple-semigroupoids/src/Data/Semigroupoid/Simple/Auto.hs +++ b/simple-semigroupoids/src/Data/Semigroupoid/Simple/Auto.hs @@ -7,10 +7,8 @@ module Data.Semigroupoid.Simple.Auto (Auto (..)) where import Data.Group (Group (..)) - -import Test.QuickCheck - import Data.Semigroupoid.Simple +import Test.QuickCheck -- | Automatically derive type class instances for groupoid-like structures -- from type class instances for group-like structures. diff --git a/simple-semigroupoids/src/Data/Semigroupoid/Simple/Laws.hs b/simple-semigroupoids/src/Data/Semigroupoid/Simple/Laws.hs index 3fe208f..6cf1419 100644 --- a/simple-semigroupoids/src/Data/Semigroupoid/Simple/Laws.hs +++ b/simple-semigroupoids/src/Data/Semigroupoid/Simple/Laws.hs @@ -33,13 +33,10 @@ import Data.Maybe (fromJust) import Data.Proxy import Data.Semigroupoid.Simple import Data.Typeable - import Test.QuickCheck import Test.Tasty (TestTree, testGroup) import Test.Tasty.QuickCheck (testProperty) - - {------------------------------------------------------------------------------ @Test.Tasty@ combinators ------------------------------------------------------------------------------} diff --git a/simple-semigroupoids/test/Main.hs b/simple-semigroupoids/test/Main.hs index 11877d6..fb5262a 100644 --- a/simple-semigroupoids/test/Main.hs +++ b/simple-semigroupoids/test/Main.hs @@ -1,10 +1,7 @@ module Main (main) where -import Test.Tasty - import Test.Data.Semigroupoid.Simple (tests) - - +import Test.Tasty main :: IO () main = defaultMain $ diff --git a/simple-semigroupoids/test/Test/Data/Semigroupoid/Simple.hs b/simple-semigroupoids/test/Test/Data/Semigroupoid/Simple.hs index 8c35d7e..1c6c708 100644 --- a/simple-semigroupoids/test/Test/Data/Semigroupoid/Simple.hs +++ b/simple-semigroupoids/test/Test/Data/Semigroupoid/Simple.hs @@ -4,14 +4,10 @@ module Test.Data.Semigroupoid.Simple (tests) where import Data.Monoid (Sum (..)) import Data.Proxy - -import Test.Tasty -import Test.Tasty.QuickCheck - import Data.Semigroupoid.Simple.Auto import Data.Semigroupoid.Simple.Laws - - +import Test.Tasty +import Test.Tasty.QuickCheck tests :: TestTree tests = testGroup "Semigroupoid" [ From d6e309b5ae00e78dcdf078ffcccfac0d45061231 Mon Sep 17 00:00:00 2001 From: Joris Date: Wed, 3 May 2023 13:01:15 +0200 Subject: [PATCH 2/2] Resolve PR comment --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 74c5b50..53d9cce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,7 @@ The following are requirements for merging a PR into `main`: * Each commit should be small and should preferably address one thing. Commit messages should be useful. * Document and test your changes. * The PR should have a useful description, and it should link issues that it - resolves. + resolves (if any). * Changes introduced by the PR should be recorded in the relevant changelog files. * PRs should not bundle many unrelated changes.