Closed martijnbastiaan closed 3 months ago
I took a look at both cabal-gild
and cabal-fmt
and concluded that these formatters would severely impact the clarity of our cabal files simply because they do not handle comments nicely.
We use comments to explain why we add certain flags or enable pragmas, but these comments are moved to another location.
Below you can find the diffs introduced by the different tools:
cabal-gild
--- /home/lucas/bittide-hardware/bittide/bittide.cabal
+++ /home/lucas/bittide-hardware/bittide/bittide.cabal.fmt
@@ -1,19 +1,26 @@
-cabal-version: 2.4
-name: bittide
-synopsis: Bittide hardware descriptions, which should be
- target independent, loosely connected / standalone
-version: 0.1
-License: Apache-2.0
-license-file: LICENSE
-author: QBayLogic B.V.
-maintainer: devops@qbaylogic.com
-Copyright: Copyright © 2022-2024 Google LLC
-
+cabal-version: 2.4
+name: bittide
+synopsis:
+ Bittide hardware descriptions, which should be
+ target independent, loosely connected / standalone
+
+version: 0.1
+license: Apache-2.0
+license-file: LICENSE
+author: QBayLogic B.V.
+maintainer: devops@qbaylogic.com
+copyright: Copyright © 2022-2024 Google LLC
data-files:
data/clock_configs/*.csv
custom-setup
- setup-depends: Cabal, base, directory, process, filepath, extra
+ setup-depends:
+ Cabal,
+ base,
+ directory,
+ extra,
+ filepath,
+ process,
-- You probably want add a `cabal.project.local` that looks like:
--
@@ -25,11 +32,15 @@
Enable the Rust FFI for the Callisto clock control. Disable this if you want
working HLS for the bittide package. Obviously, any tests using the Callisto
Rust implementation will fail.
+
default: True
manual: True
common common-options
default-extensions:
+ -- TemplateHaskell is used to support convenience functions such as
+ -- 'listToVecTH' and 'bLit'.
+ -- Prelude isn't imported by default as Clash offers Clash.Prelude
BangPatterns
BinaryLiterals
ConstraintKinds
@@ -46,53 +57,51 @@
InstanceSigs
KindSignatures
LambdaCase
+ NoImplicitPrelude
NoStarIsType
PolyKinds
+ QuasiQuotes
RankNTypes
ScopedTypeVariables
StandaloneDeriving
+ TemplateHaskell
TupleSections
TypeApplications
TypeFamilies
TypeOperators
ViewPatterns
- -- TemplateHaskell is used to support convenience functions such as
- -- 'listToVecTH' and 'bLit'.
- TemplateHaskell
- QuasiQuotes
-
- -- Prelude isn't imported by default as Clash offers Clash.Prelude
- NoImplicitPrelude
ghc-options:
- -Wall -Wcompat
-- Plugins to support type-level constraint solving on naturals
- -fplugin GHC.TypeLits.Extra.Solver
- -fplugin GHC.TypeLits.Normalise
- -fplugin GHC.TypeLits.KnownNat.Solver
- -fconstraint-solver-iterations=8
-
-- Clash needs access to the source code in compiled modules
- -fexpose-all-unfoldings
-
-- Worker wrappers introduce unstable names for functions that might have
-- blackboxes attached for them. You can disable this, but be sure to add
-- a no-specialize pragma to every function with a blackbox.
- -fno-worker-wrapper
-
-- Strict annotations - while sometimes preventing space leaks - trigger
-- optimizations Clash can't deal with. See:
--
-- https://github.com/clash-lang/clash-compiler/issues/2361
--
-- These flags disables the optimization.
+ -Wall
+ -Wcompat
+ -fplugin
+ GHC.TypeLits.Extra.Solver
+ -fplugin
+ GHC.TypeLits.Normalise
+ -fplugin
+ GHC.TypeLits.KnownNat.Solver
+ -fconstraint-solver-iterations=8
+ -fexpose-all-unfoldings
+ -fno-worker-wrapper
-fno-unbox-small-strict-fields
-fno-unbox-strict-fields
+
default-language: Haskell2010
build-depends:
- ghc-typelits-extra >= 0.4.4,
- ghc-typelits-knownnat >= 0.7.7,
- ghc-typelits-natnormalise >= 0.7.7,
+ ghc-typelits-extra >=0.4.4,
+ ghc-typelits-knownnat >=0.7.7,
+ ghc-typelits-natnormalise >=0.7.7,
library
import: common-options
@@ -106,12 +115,12 @@
bytestring,
cassava,
clash-cores,
- clash-lib >= 1.6.3 && < 1.10,
- clash-prelude >= 1.6.3 && < 1.10,
+ clash-lib >=1.6.3 && <1.10,
+ clash-prelude >=1.6.3 && <1.10,
clash-protocols,
clash-vexriscv,
- constraints >= 0.13.3 && < 0.15,
- containers >= 0.4.0 && < 0.7,
+ constraints >=0.13.3 && <0.15,
+ containers >=0.4.0 && <0.7,
directory,
elf,
exceptions,
@@ -122,9 +131,10 @@
pretty-show,
process,
random,
- string-interpolate ^>= 0.3,
+ string-interpolate ^>=0.3,
template-haskell,
text,
+
exposed-modules:
Bittide.Arithmetic.Ppm
Bittide.Arithmetic.Time
@@ -174,6 +184,7 @@
Clash.Sized.Extra
Data.Constraint.Nat.Extra
System.IO.Temp.Extra
+
other-modules:
Paths_bittide
@@ -182,24 +193,33 @@
cpp-options: -DRUSTY_CALLISTO
test-suite doctests
- type: exitcode-stdio-1.0
+ type: exitcode-stdio-1.0
default-language: Haskell2010
- main-is: doctests.hs
- ghc-options: -Wall -Wcompat -threaded
- hs-source-dirs: tests
-
+ main-is: doctests.hs
+ ghc-options:
+ -Wall
+ -Wcompat
+ -threaded
+
+ hs-source-dirs: tests
build-depends:
base,
bittide,
- doctest-parallel >= 0.3.0.1 && < 0.4,
- filepath
+ doctest-parallel >=0.3.0.1 && <0.4,
+ filepath,
test-suite unittests
import: common-options
hs-source-dirs: tests
type: exitcode-stdio-1.0
main-is: UnitTests.hs
- ghc-options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-N12
+ ghc-options:
+ -Wall
+ -Wcompat
+ -threaded
+ -rtsopts
+ -with-rtsopts=-N12
+
other-modules:
Tests.Axi4
Tests.Calendar
@@ -213,29 +233,29 @@
Tests.Shared
Tests.StabilityChecker
Tests.Switch
+ Tests.Transceiver
Tests.Transceiver.Prbs
Tests.Transceiver.WordAlign
- Tests.Transceiver
Tests.Wishbone
- build-depends:
- base,
+
+ build-depends:
+ HUnit,
+ base,
+ bittide,
bittide-extra,
- bittide,
bytestring,
clash-cores,
clash-lib,
- clash-prelude-hedgehog >= 1.6 && < 1.10,
clash-prelude,
+ clash-prelude-hedgehog >=1.6 && <1.10,
clash-protocols,
- constraints >= 0.13.3 && < 0.15,
- containers,
+ constraints >=0.13.3 && <0.15,
containers,
elf,
extra,
- hedgehog >= 1.0 && < 1.5,
- HUnit,
- tasty >= 1.4 && < 1.6,
+ hedgehog >=1.0 && <1.5,
+ tasty >=1.4 && <1.6,
tasty-expected-failure,
- tasty-hedgehog >= 1.2 && < 1.5,
+ tasty-hedgehog >=1.2 && <1.5,
tasty-hunit,
tasty-th,
cabal-fmt
--- /home/lucas/bittide-hardware/bittide/bittide.cabal
+++ /home/lucas/bittide-hardware/bittide/bittide.cabal.fmt
@@ -1,19 +1,25 @@
-cabal-version: 2.4
-name: bittide
-synopsis: Bittide hardware descriptions, which should be
- target independent, loosely connected / standalone
-version: 0.1
-License: Apache-2.0
-license-file: LICENSE
-author: QBayLogic B.V.
-maintainer: devops@qbaylogic.com
-Copyright: Copyright © 2022-2024 Google LLC
-
-data-files:
- data/clock_configs/*.csv
+cabal-version: 2.4
+name: bittide
+synopsis:
+ Bittide hardware descriptions, which should be
+ target independent, loosely connected / standalone
+
+version: 0.1
+license: Apache-2.0
+license-file: LICENSE
+author: QBayLogic B.V.
+maintainer: devops@qbaylogic.com
+copyright: Copyright © 2022-2024 Google LLC
+data-files: data/clock_configs/*.csv
custom-setup
- setup-depends: Cabal, base, directory, process, filepath, extra
+ setup-depends:
+ , base
+ , Cabal
+ , directory
+ , extra
+ , filepath
+ , process
-- You probably want add a `cabal.project.local` that looks like:
--
@@ -25,8 +31,9 @@
Enable the Rust FFI for the Callisto clock control. Disable this if you want
working HLS for the bittide package. Obviously, any tests using the Callisto
Rust implementation will fail.
- default: True
- manual: True
+
+ default: True
+ manual: True
common common-options
default-extensions:
@@ -46,85 +53,79 @@
InstanceSigs
KindSignatures
LambdaCase
+ NoImplicitPrelude
NoStarIsType
PolyKinds
+ QuasiQuotes
RankNTypes
ScopedTypeVariables
StandaloneDeriving
+ TemplateHaskell
TupleSections
TypeApplications
TypeFamilies
TypeOperators
ViewPatterns
- -- TemplateHaskell is used to support convenience functions such as
- -- 'listToVecTH' and 'bLit'.
- TemplateHaskell
- QuasiQuotes
-
- -- Prelude isn't imported by default as Clash offers Clash.Prelude
- NoImplicitPrelude
+ -- TemplateHaskell is used to support convenience functions such as
+ -- 'listToVecTH' and 'bLit'.
+ -- Prelude isn't imported by default as Clash offers Clash.Prelude
ghc-options:
- -Wall -Wcompat
- -- Plugins to support type-level constraint solving on naturals
- -fplugin GHC.TypeLits.Extra.Solver
- -fplugin GHC.TypeLits.Normalise
- -fplugin GHC.TypeLits.KnownNat.Solver
- -fconstraint-solver-iterations=8
-
- -- Clash needs access to the source code in compiled modules
- -fexpose-all-unfoldings
-
- -- Worker wrappers introduce unstable names for functions that might have
- -- blackboxes attached for them. You can disable this, but be sure to add
- -- a no-specialize pragma to every function with a blackbox.
- -fno-worker-wrapper
-
- -- Strict annotations - while sometimes preventing space leaks - trigger
- -- optimizations Clash can't deal with. See:
- --
- -- https://github.com/clash-lang/clash-compiler/issues/2361
- --
- -- These flags disables the optimization.
- -fno-unbox-small-strict-fields
+ -Wall -Wcompat -fplugin GHC.TypeLits.Extra.Solver -fplugin
+ GHC.TypeLits.Normalise -fplugin GHC.TypeLits.KnownNat.Solver
+ -fconstraint-solver-iterations=8 -fexpose-all-unfoldings
+ -fno-worker-wrapper -fno-unbox-small-strict-fields
-fno-unbox-strict-fields
- default-language: Haskell2010
- build-depends:
- ghc-typelits-extra >= 0.4.4,
- ghc-typelits-knownnat >= 0.7.7,
- ghc-typelits-natnormalise >= 0.7.7,
+
+ -- Plugins to support type-level constraint solving on naturals
+ -- Clash needs access to the source code in compiled modules
+ -- Worker wrappers introduce unstable names for functions that might have
+ -- blackboxes attached for them. You can disable this, but be sure to add
+ -- a no-specialize pragma to every function with a blackbox.
+ -- Strict annotations - while sometimes preventing space leaks - trigger
+ -- optimizations Clash can't deal with. See:
+ --
+ -- https://github.com/clash-lang/clash-compiler/issues/2361
+ --
+ -- These flags disables the optimization.
+ default-language: Haskell2010
+ build-depends:
+ , ghc-typelits-extra >=0.4.4
+ , ghc-typelits-knownnat >=0.7.7
+ , ghc-typelits-natnormalise >=0.7.7
library
- import: common-options
- hs-source-dirs: src
- build-depends:
- Cabal,
- aeson,
- array,
- base,
- bittide-extra,
- bytestring,
- cassava,
- clash-cores,
- clash-lib >= 1.6.3 && < 1.10,
- clash-prelude >= 1.6.3 && < 1.10,
- clash-protocols,
- clash-vexriscv,
- constraints >= 0.13.3 && < 0.15,
- containers >= 0.4.0 && < 0.7,
- directory,
- elf,
- exceptions,
- extra,
- filepath,
- infinite-list,
- mtl,
- pretty-show,
- process,
- random,
- string-interpolate ^>= 0.3,
- template-haskell,
- text,
+ import: common-options
+ hs-source-dirs: src
+ build-depends:
+ , aeson
+ , array
+ , base
+ , bittide-extra
+ , bytestring
+ , Cabal
+ , cassava
+ , clash-cores
+ , clash-lib >=1.6.3 && <1.10
+ , clash-prelude >=1.6.3 && <1.10
+ , clash-protocols
+ , clash-vexriscv
+ , constraints >=0.13.3 && <0.15
+ , containers >=0.4.0 && <0.7
+ , directory
+ , elf
+ , exceptions
+ , extra
+ , filepath
+ , infinite-list
+ , mtl
+ , pretty-show
+ , process
+ , random
+ , string-interpolate ^>=0.3
+ , template-haskell
+ , text
+
exposed-modules:
Bittide.Arithmetic.Ppm
Bittide.Arithmetic.Time
@@ -174,12 +175,12 @@
Clash.Sized.Extra
Data.Constraint.Nat.Extra
System.IO.Temp.Extra
- other-modules:
- Paths_bittide
+
+ other-modules: Paths_bittide
if flag(rusty-callisto)
extra-libraries: callisto_lib
- cpp-options: -DRUSTY_CALLISTO
+ cpp-options: -DRUSTY_CALLISTO
test-suite doctests
type: exitcode-stdio-1.0
@@ -187,19 +188,18 @@
main-is: doctests.hs
ghc-options: -Wall -Wcompat -threaded
hs-source-dirs: tests
-
- build-depends:
- base,
- bittide,
- doctest-parallel >= 0.3.0.1 && < 0.4,
- filepath
+ build-depends:
+ , base
+ , bittide
+ , doctest-parallel >=0.3.0.1 && <0.4
+ , filepath
test-suite unittests
- import: common-options
+ import: common-options
hs-source-dirs: tests
- type: exitcode-stdio-1.0
- main-is: UnitTests.hs
- ghc-options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-N12
+ type: exitcode-stdio-1.0
+ main-is: UnitTests.hs
+ ghc-options: -Wall -Wcompat -threaded -rtsopts -with-rtsopts=-N12
other-modules:
Tests.Axi4
Tests.Calendar
@@ -213,29 +213,29 @@
Tests.Shared
Tests.StabilityChecker
Tests.Switch
+ Tests.Transceiver
Tests.Transceiver.Prbs
Tests.Transceiver.WordAlign
- Tests.Transceiver
Tests.Wishbone
- build-depends:
- base,
- bittide-extra,
- bittide,
- bytestring,
- clash-cores,
- clash-lib,
- clash-prelude-hedgehog >= 1.6 && < 1.10,
- clash-prelude,
- clash-protocols,
- constraints >= 0.13.3 && < 0.15,
- containers,
- containers,
- elf,
- extra,
- hedgehog >= 1.0 && < 1.5,
- HUnit,
- tasty >= 1.4 && < 1.6,
- tasty-expected-failure,
- tasty-hedgehog >= 1.2 && < 1.5,
- tasty-hunit,
- tasty-th,
+
+ build-depends:
+ , base
+ , bittide
+ , bittide-extra
+ , bytestring
+ , clash-cores
+ , clash-lib
+ , clash-prelude
+ , clash-prelude-hedgehog >=1.6 && <1.10
+ , clash-protocols
+ , constraints >=0.13.3 && <0.15
+ , containers
+ , elf
+ , extra
+ , hedgehog >=1.0 && <1.5
+ , HUnit
+ , tasty >=1.4 && <1.6
+ , tasty-expected-failure
+ , tasty-hedgehog >=1.2 && <1.5
+ , tasty-hunit
+ , tasty-th
We chose to add the explained flags to the comment blocks. This will be fixed by #583
https://taylor.fausak.me/2024/02/17/gild/