Skip to content

Commit

Permalink
Make fourmolu happy
Browse files Browse the repository at this point in the history
Cabal codebase has now a formatter/style standard (see haskell#8950).

“Ravioli ravioli, give me the formuoli”
  • Loading branch information
ffaf1 committed Sep 19, 2023
1 parent ebb5ee3 commit 72cdc35
Show file tree
Hide file tree
Showing 9 changed files with 3,209 additions and 2,501 deletions.
39 changes: 25 additions & 14 deletions Cabal-syntax/src/Distribution/Types/UnqualComponentName.hs
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,29 @@ unqualComponentNameToPackageName = mkPackageNameST . unUnqualComponentNameST
-- | Combine names in targets if one name is empty or both names are equal
-- (partial function).
-- Useful in 'Semigroup' and similar instances.
combineNames :: a -> a -> (a -> UnqualComponentName) -> String ->
UnqualComponentName
combineNames
:: a
-> a
-> (a -> UnqualComponentName)
-> String
-> UnqualComponentName
combineNames a b tacc tt
-- One empty or the same.
| P.null unb ||
una == unb = na
| P.null una = nb
-- Both non-empty, different.
| otherwise = error $ "Ambiguous values for " ++ tt ++ " field: '"
++ una ++ "' and '" ++ unb ++ "'"
where
(na, nb) = (tacc a, tacc b)
una = unUnqualComponentName na
unb = unUnqualComponentName nb

-- One empty or the same.
| P.null unb
|| una == unb =
na
| P.null una = nb
-- Both non-empty, different.
| otherwise =
error $
"Ambiguous values for "
++ tt
++ " field: '"
++ una
++ "' and '"
++ unb
++ "'"
where
(na, nb) = (tacc a, tacc b)
una = unUnqualComponentName na
unb = unUnqualComponentName nb
Loading

0 comments on commit 72cdc35

Please sign in to comment.