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 Jun 1, 2023
1 parent 747fece commit a171627
Show file tree
Hide file tree
Showing 10 changed files with 3,233 additions and 2,525 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 a171627

Please sign in to comment.