Skip to content

Commit cc61062

Browse files
committed
Formatting with fourmolu
1 parent b18d165 commit cc61062

File tree

19 files changed

+780
-711
lines changed

19 files changed

+780
-711
lines changed

.github/workflows/formatting.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Check code formatting
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on:
9+
- ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v4
13+
14+
- uses: haskell-actions/run-fourmolu@v9
15+
with:
16+
version: "0.14.0.0"

app/Distribution/Aeson.hs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -144,33 +144,33 @@ jsonField fn v
144144
| v == emptyArray = mempty
145145
| v == emptyString = mempty
146146
| otherwise = [Key.fromString (fromUTF8BS fn) .= v]
147-
where
148-
-- Should be added to aeson
149-
emptyString :: Value
150-
emptyString = String ""
147+
where
148+
-- Should be added to aeson
149+
emptyString :: Value
150+
emptyString = String ""
151151

152152
jsonGenericPackageDescription :: GenericPackageDescription -> Value
153153
jsonGenericPackageDescription gpd = jsonGenericPackageDescription' v gpd
154-
where
155-
v = specVersion $ packageDescription gpd
154+
where
155+
v = specVersion $ packageDescription gpd
156156

157157
jsonGenericPackageDescription' :: CabalSpecVersion -> GenericPackageDescription -> Value
158158
jsonGenericPackageDescription' v gpd =
159159
object $
160160
concat
161-
[ jsonPackageDescription v (packageDescription gpd),
162-
jsonSetupBuildInfo v (setupBuildInfo (packageDescription gpd)),
163-
jsonGenPackageFlags v (genPackageFlags gpd),
164-
jsonCondLibrary v (condLibrary gpd),
165-
jsonCondSubLibraries v (condSubLibraries gpd),
166-
jsonCondForeignLibs v (condForeignLibs gpd),
167-
jsonCondExecutables v (condExecutables gpd),
168-
jsonCondTestSuites v (condTestSuites gpd),
169-
jsonCondBenchmarks v (condBenchmarks gpd)
161+
[ jsonPackageDescription v (packageDescription gpd)
162+
, jsonSetupBuildInfo v (setupBuildInfo (packageDescription gpd))
163+
, jsonGenPackageFlags v (genPackageFlags gpd)
164+
, jsonCondLibrary v (condLibrary gpd)
165+
, jsonCondSubLibraries v (condSubLibraries gpd)
166+
, jsonCondForeignLibs v (condForeignLibs gpd)
167+
, jsonCondExecutables v (condExecutables gpd)
168+
, jsonCondTestSuites v (condTestSuites gpd)
169+
, jsonCondBenchmarks v (condBenchmarks gpd)
170170
]
171171

172172
jsonPackageDescription :: CabalSpecVersion -> PackageDescription -> [Pair]
173-
jsonPackageDescription v pd@PackageDescription {sourceRepos, setupBuildInfo} =
173+
jsonPackageDescription v pd@PackageDescription{sourceRepos, setupBuildInfo} =
174174
jsonFieldGrammar v packageDescriptionFieldGrammar pd
175175
<> jsonSourceRepos v sourceRepos
176176
<> jsonSetupBuildInfo v setupBuildInfo
@@ -180,7 +180,7 @@ jsonSourceRepos v =
180180
concatMap (\neRepos -> ["source-repository" .= NE.map (jsonSourceRepo v) neRepos]) . NE.nonEmpty
181181

182182
jsonSourceRepo :: CabalSpecVersion -> SourceRepo -> Value
183-
jsonSourceRepo v repo@SourceRepo {repoKind} =
183+
jsonSourceRepo v repo@SourceRepo{repoKind} =
184184
object $ jsonFieldGrammar v (sourceRepoFieldGrammar repoKind) repo
185185

186186
jsonSetupBuildInfo :: CabalSpecVersion -> Maybe SetupBuildInfo -> [Pair]
@@ -241,33 +241,33 @@ jsonCondBenchmark v (n, condTree) =
241241

242242
jsonCondTree :: forall a. CabalSpecVersion -> JSONFieldGrammar' a -> CondTree ConfVar [Dependency] a -> Value
243243
jsonCondTree v grammar = toJSON . go . fmap fst . conv
244-
where
245-
go (CondFlat a ifs) =
246-
KeyMap.fromListWith (<>) $
247-
second (: [])
248-
<$> jsonFieldGrammar v grammar a ++ concatMap (\(cv, a') -> second (ifc cv) <$> jsonFieldGrammar v grammar a') ifs
244+
where
245+
go (CondFlat a ifs) =
246+
KeyMap.fromListWith (<>) $
247+
second (: [])
248+
<$> jsonFieldGrammar v grammar a ++ concatMap (\(cv, a') -> second (ifc cv) <$> jsonFieldGrammar v grammar a') ifs
249249

250-
ifc cv a = object ["if" .= showCondition cv, "then" .= a]
250+
ifc cv a = object ["if" .= showCondition cv, "then" .= a]
251251

252252
data CondFlat v a = CondFlat a [(Condition v, a)]
253253
deriving (Show, Functor)
254254

255255
conv :: forall v c a. CondTree v c a -> CondFlat v (a, c)
256256
conv = goNode
257-
where
258-
goNode (CondNode a c ifs) =
259-
CondFlat (a, c) (concatMap goBranch ifs)
260-
261-
goBranch (CondBranch cond thenTree Nothing) =
262-
let (CondFlat a ifs) = goNode thenTree
263-
in (cond, a) : fmap (first (cond `cAnd`)) ifs
264-
goBranch (CondBranch cond thenTree (Just elseTree)) =
265-
let (CondFlat a1 ifs1) = goNode thenTree
266-
(CondFlat a2 ifs2) = goNode elseTree
267-
in (cond, a1)
268-
: (first (cond `cAnd`) <$> ifs1)
269-
++ (cNot cond, a2)
270-
: (first (cNot cond `cAnd`) <$> ifs2)
257+
where
258+
goNode (CondNode a c ifs) =
259+
CondFlat (a, c) (concatMap goBranch ifs)
260+
261+
goBranch (CondBranch cond thenTree Nothing) =
262+
let (CondFlat a ifs) = goNode thenTree
263+
in (cond, a) : fmap (first (cond `cAnd`)) ifs
264+
goBranch (CondBranch cond thenTree (Just elseTree)) =
265+
let (CondFlat a1 ifs1) = goNode thenTree
266+
(CondFlat a2 ifs2) = goNode elseTree
267+
in (cond, a1)
268+
: (first (cond `cAnd`) <$> ifs1)
269+
++ (cNot cond, a2)
270+
: (first (cNot cond `cAnd`) <$> ifs2)
271271

272272
test :: FilePath -> IO ()
273273
test fn = do

0 commit comments

Comments
 (0)