Skip to content

Commit 08ad881

Browse files
authored
Update linting tooling (#179)
* Use fourmolu v0.17.0.0 and cabal-gild * format the code * Ignore the formatting commit
1 parent 4fb4324 commit 08ad881

39 files changed

+192
-148
lines changed

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# fourmolu 0.17.0.0 and cabal-gild formatting
2+
eab5847b465349bdda613f00dec7f31d83bb1f6d

.github/workflows/linting.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313

1414
- uses: haskell-actions/run-fourmolu@v11
1515
with:
16-
version: "0.14.1.0"
16+
version: "0.17.0.0"
1717
pattern: |
1818
sel/**/*.hs
1919
libsodium-bindings/**/*.hs

CONTRIBUTING.md

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ We need you to read, acknowledge, and abide by our [Code of Conduct][CoC].
1010

1111
When making a PR, ensure that you have a Github issue that explains the context for your changes.
1212

13-
## Code Style
13+
## Code Style
1414

1515
### C FFI
1616

1717
* The [CApiFFI convention](https://www.haskell.org/ghc/blog/20210709-capi-usage.html) must be used at all times.
1818
* The datatypes from [`Foreign`](https://hackage.haskell.org/package/base/docs/Foreign.html) must be used when
1919
getting results from C, like `CInt` in favour of `Int`.
20-
Example:
20+
Example:
2121
-`foreign export ccall sodium_init :: IO Int`
2222

2323
-`foreign import capi "sodium.h sodium_init" c_sodium_init :: IO CInt`
@@ -28,14 +28,12 @@ We have a git hook in place to ensure the following formatting and linting tools
2828
are being used:
2929

3030
* All Haskell source files are formatted with
31-
[`fourmolu`](https://hackage.haskell.org/package/fourmolu);
32-
* All Haskell source files are linted with
33-
[HLint](https://hackage.haskell.org/package/hlint), as per the `.hlint.yaml`
31+
[`fourmolu`](https://flora.pm/packages/@hackage/fourmolu/0.17.0.0) v0.17.0.0;
32+
* All Haskell source files are linted with
33+
[`hlint` v3.8](https://flora.pm/packages/@hackage/hlint/3.8), as per the `.hlint.yaml`
3434
configuration file.
3535
* The Cabal file is formatted with
36-
[`cabal-fmt`](https://github.com/phadej/cabal-fmt)
37-
38-
Check the version of these tools in https://github.com/haskell-cryptography/libsodium-bindings/blob/main/.github/workflows/linting.yml.
36+
[`cabal-gild` v1.5.0.1](https://flora.pm/packages/@hackage/cabal-gild/1.5.0.1)
3937

4038
To ensure that you are using the git hook, run the following, once:
4139

@@ -45,7 +43,7 @@ git config core.hooksPath .githooks
4543

4644
You can also use the provided `Makefile` by running `make init`.
4745

48-
### Questions
46+
### Questions
4947

5048
Open a thread in the [Questions][Questions board] discussion board. That way,
5149
you can get help from everyone in the community.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ lint: ## Run the code linter (HLint)
2323
@find sel libsodium-bindings -name "*.hs" | xargs -P $(PROCS) -I {} hlint --refactor-options="-i" --refactor {}
2424

2525
style: ## Run the code formatter (fourmolu, cabal-fmt)
26-
@cabal-fmt -i **/**.cabal
26+
@cabal-gild --mode=format --io=libsodium-bindings/libsodium-bindings.cabal
27+
@cabal-gild --mode=format --io=sel/sel.cabal
2728
@fourmolu -q --mode inplace sel libsodium-bindings
2829

2930
help: ## Display this help message

fourmolu.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ newlines-between-decls: 1 # number of newlines between top-level declarations
99
fixities: []
1010
function-arrows: leading
1111
single-constraint-parens: never
12+
import-grouping: by-scope
13+
sort-constraints: true
14+
sort-derived-classes: true
15+
sort-deriving-clauses: true
Lines changed: 42 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,81 @@
1-
cabal-version: 3.0
2-
name: libsodium-bindings
3-
version: 0.0.3.0
4-
category: Cryptography
5-
synopsis: FFI bindings to libsodium
1+
cabal-version: 3.0
2+
name: libsodium-bindings
3+
version: 0.0.3.0
4+
category: Cryptography
5+
synopsis: FFI bindings to libsodium
66
description:
77
This library embeds FFI bindings to the stable version of libsodium 1.0.18.
88
The interface exposed by this library is kept close to the C library.
99

10-
homepage: https://github.com/haskell-cryptography/libsodium-bindings
10+
homepage: https://github.com/haskell-cryptography/libsodium-bindings
1111
bug-reports:
1212
https://github.com/haskell-cryptography/libsodium-bindings/issues
1313

14-
author: Hécate Moonlight, Koz Ross
15-
maintainer: The Haskell Cryptography contributors
16-
license: BSD-3-Clause
17-
build-type: Simple
14+
author: Hécate Moonlight, Koz Ross
15+
maintainer: The Haskell Cryptography contributors
16+
license: BSD-3-Clause
17+
build-type: Simple
1818
tested-with:
19-
GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1
19+
ghc ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1
2020

2121
extra-source-files:
2222
LICENSE
2323
README.md
2424

25-
extra-doc-files: CHANGELOG.md
25+
extra-doc-files: CHANGELOG.md
2626

2727
flag pkg-config
2828
description: Use pkg-config to find Libsodium (macOS and linux only).
29-
default: False
30-
manual: True
29+
default: False
30+
manual: True
3131

3232
flag homebrew
3333
description: Use Homebrew version of Libsodium (macOS only).
34-
default: False
35-
manual: True
34+
default: False
35+
manual: True
3636

3737
source-repository head
38-
type: git
38+
type: git
3939
location: https://github.com/haskell-cryptography/libsodium-bindings
4040

4141
common common
42-
build-depends: base >=4.14 && <5
42+
build-depends: base >=4.14 && <5
4343
ghc-options:
44-
-Wall -Wcompat -Widentities -Wincomplete-record-updates
45-
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints
46-
-fhide-source-paths -Wno-unused-do-bind
44+
-Wall
45+
-Wcompat
46+
-Widentities
47+
-Wincomplete-record-updates
48+
-Wincomplete-uni-patterns
49+
-Wpartial-fields
50+
-Wredundant-constraints
51+
-fhide-source-paths
52+
-Wno-unused-do-bind
4753

4854
if (os(osx) && flag(homebrew))
49-
include-dirs: /opt/local/include /opt/homebrew/include
50-
extra-lib-dirs: /user/local/opt/libsodium/lib /opt/homebrew/lib
55+
include-dirs:
56+
/opt/homebrew/include
57+
/opt/local/include
58+
59+
extra-lib-dirs:
60+
/opt/homebrew/lib
61+
/user/local/opt/libsodium/lib
5162

5263
if flag(pkg-config)
5364
pkgconfig-depends: libsodium >=1.0.18
54-
5565
else
5666
extra-libraries: sodium
5767

5868
default-language: Haskell2010
5969

6070
common common-rts-options
61-
ghc-options: -rtsopts -threaded -with-rtsopts=-N
71+
ghc-options:
72+
-rtsopts
73+
-threaded
74+
-with-rtsopts=-N
6275

6376
library
64-
import: common
65-
hs-source-dirs: src
66-
77+
import: common
78+
hs-source-dirs: src
6779
-- cabal-fmt: expand src/
6880
exposed-modules:
6981
LibSodium.Bindings
@@ -78,12 +90,12 @@ library
7890
LibSodium.Bindings.Main
7991
LibSodium.Bindings.PasswordHashing
8092
LibSodium.Bindings.Random
93+
LibSodium.Bindings.SHA2
8194
LibSodium.Bindings.Scrypt
8295
LibSodium.Bindings.SealedBoxes
83-
LibSodium.Bindings.Secretbox
8496
LibSodium.Bindings.SecretStream
97+
LibSodium.Bindings.Secretbox
8598
LibSodium.Bindings.SecureMemory
86-
LibSodium.Bindings.SHA2
8799
LibSodium.Bindings.ShortHashing
88100
LibSodium.Bindings.Utils
89101
LibSodium.Bindings.XChaCha20

libsodium-bindings/src/LibSodium/Bindings/SealedBoxes.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ module LibSodium.Bindings.SealedBoxes
2323

2424
import Foreign (Ptr)
2525
import Foreign.C (CInt (CInt), CSize (CSize), CUChar, CULLong (CULLong))
26+
2627
import LibSodium.Bindings.CryptoBox (cryptoBoxKeyPair, cryptoBoxSeedKeyPair)
2728

2829
-- $introduction

libsodium-bindings/src/LibSodium/Bindings/ShortHashing.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module LibSodium.Bindings.ShortHashing
3535
import Data.Word (Word8)
3636
import Foreign.C (CInt (CInt), CSize (CSize), CUChar, CULLong (CULLong))
3737
import Foreign.Ptr (Ptr, castPtr)
38+
3839
import LibSodium.Bindings.Random (randombytesBuf)
3940

4041
-- | Create a secret key of size 'cryptoShortHashKeyBytes'.

sel/sel.cabal

Lines changed: 58 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,70 @@
1-
cabal-version: 3.0
2-
name: sel
3-
version: 0.0.3.0
4-
category: Cryptography
5-
synopsis: Cryptography for the casual user
1+
cabal-version: 3.0
2+
name: sel
3+
version: 0.0.3.0
4+
category: Cryptography
5+
synopsis: Cryptography for the casual user
66
description:
77
The high-level library aimed at casual users of cryptography, by the Haskell Cryptography Group
88

9-
homepage: https://github.com/haskell-cryptography/libsodium-bindings
9+
homepage: https://github.com/haskell-cryptography/libsodium-bindings
1010
bug-reports:
1111
https://github.com/haskell-cryptography/libsodium-bindings/issues
1212

13-
author: Hécate Moonlight, Koz Ross
14-
maintainer: The Haskell Cryptography contributors
15-
license: BSD-3-Clause
16-
build-type: Simple
13+
author: Hécate Moonlight, Koz Ross
14+
maintainer: The Haskell Cryptography contributors
15+
license: BSD-3-Clause
16+
build-type: Simple
1717
tested-with:
18-
GHC ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1
18+
ghc ==9.2.8 || ==9.4.8 || ==9.6.6 || ==9.8.2 || ==9.10.1
1919

2020
extra-source-files:
2121
LICENSE
2222
README.md
2323

24-
extra-doc-files: CHANGELOG.md
24+
extra-doc-files: CHANGELOG.md
2525

2626
source-repository head
27-
type: git
27+
type: git
2828
location: https://github.com/haskell-cryptography/libsodium-bindings
2929

3030
common common
3131
ghc-options:
32-
-Wall -Wcompat -Widentities -Wincomplete-record-updates
33-
-Wincomplete-uni-patterns -Wpartial-fields -Wredundant-constraints
34-
-fhide-source-paths -Wno-unused-do-bind -fshow-hole-constraints
35-
-fprint-potential-instances -Wno-unticked-promoted-constructors
32+
-Wall
33+
-Wcompat
34+
-Widentities
35+
-Wincomplete-record-updates
36+
-Wincomplete-uni-patterns
37+
-Wpartial-fields
38+
-Wredundant-constraints
39+
-fhide-source-paths
40+
-Wno-unused-do-bind
41+
-fshow-hole-constraints
42+
-fprint-potential-instances
43+
-Wno-unticked-promoted-constructors
3644
-Werror=unused-imports
3745

3846
default-language: Haskell2010
3947

4048
common test-options
41-
ghc-options: -rtsopts -threaded -with-rtsopts=-N
49+
ghc-options:
50+
-rtsopts
51+
-threaded
52+
-with-rtsopts=-N
4253

4354
library
44-
import: common
45-
hs-source-dirs: src
55+
import: common
56+
hs-source-dirs: src
4657
exposed-modules:
4758
Sel
59+
Sel.HMAC
60+
Sel.HMAC.SHA256
61+
Sel.HMAC.SHA512
62+
Sel.HMAC.SHA512_256
4863
Sel.Hashing
4964
Sel.Hashing.Password
5065
Sel.Hashing.SHA256
5166
Sel.Hashing.SHA512
5267
Sel.Hashing.Short
53-
Sel.HMAC
54-
Sel.HMAC.SHA256
55-
Sel.HMAC.SHA512
56-
Sel.HMAC.SHA512_256
5768
Sel.PublicKey.Cipher
5869
Sel.PublicKey.Seal
5970
Sel.PublicKey.Signature
@@ -69,26 +80,26 @@ library
6980
Sel.Internal.Sodium
7081

7182
build-depends:
72-
, base >=4.14 && <5
73-
, base16 ^>=1.0
74-
, bytestring >=0.10 && <0.13
75-
, libsodium-bindings ^>=0.0.2
76-
, text >=1.2 && <2.2
77-
, text-builder-linear ^>=0.1
78-
, text-display ^>=1.0
79-
, transformers ^>=0.6.0
83+
base >=4.14 && <5,
84+
base16 ^>=1.0,
85+
bytestring >=0.10 && <0.13,
86+
libsodium-bindings ^>=0.0.2,
87+
text >=1.2 && <2.2,
88+
text-builder-linear ^>=0.1,
89+
text-display ^>=1.0,
90+
transformers ^>=0.6.0,
8091

8192
test-suite sel-tests
82-
import: common
83-
import: test-options
84-
type: exitcode-stdio-1.0
85-
main-is: Main.hs
93+
import: common
94+
import: test-options
95+
type: exitcode-stdio-1.0
96+
main-is: Main.hs
8697
other-modules:
98+
Test.HMAC
8799
Test.Hashing
88100
Test.Hashing.Password
89101
Test.Hashing.SHA2
90102
Test.Hashing.Short
91-
Test.HMAC
92103
Test.PublicKey.Cipher
93104
Test.PublicKey.Seal
94105
Test.PublicKey.Signature
@@ -100,13 +111,13 @@ test-suite sel-tests
100111

101112
hs-source-dirs: test
102113
build-depends:
103-
, base
104-
, base16
105-
, bytestring
106-
, hedgehog ^>=1.4
107-
, libsodium-bindings
108-
, sel
109-
, tasty >=1.4 && <1.6
110-
, tasty-hunit ^>=0.10
111-
, text
112-
, text-display
114+
base,
115+
base16,
116+
bytestring,
117+
hedgehog ^>=1.4,
118+
libsodium-bindings,
119+
sel,
120+
tasty >=1.4 && <1.6,
121+
tasty-hunit ^>=0.10,
122+
text,
123+
text-display,

sel/src/Sel/HMAC/SHA256.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ import Foreign (ForeignPtr, Ptr, Word8)
6565
import qualified Foreign
6666
import Foreign.C (CChar, CSize, CUChar, CULLong)
6767
import Foreign.C.Error (throwErrno)
68-
import System.IO.Unsafe (unsafeDupablePerformIO)
69-
7068
import LibSodium.Bindings.SHA2
7169
( CryptoAuthHMACSHA256State
7270
, cryptoAuthHMACSHA256
@@ -80,6 +78,8 @@ import LibSodium.Bindings.SHA2
8078
, cryptoAuthHMACSHA256Verify
8179
)
8280
import LibSodium.Bindings.SecureMemory (finalizerSodiumFree, sodiumMalloc)
81+
import System.IO.Unsafe (unsafeDupablePerformIO)
82+
8383
import Sel.Internal (allocateWith, foreignPtrEqConstantTime, foreignPtrOrdConstantTime)
8484
import Sel.Internal.Sodium (binaryToHex)
8585

0 commit comments

Comments
 (0)