Skip to content

Commit f213dec

Browse files
committed
format
1 parent 222978f commit f213dec

40 files changed

+6606
-6094
lines changed

.fourmolu_skip_files.txt

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/linting.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ jobs:
2020
!Cabal-syntax/src/Distribution/SPDX/LicenseExceptionId.hs
2121
!Cabal-syntax/src/Distribution/SPDX/LicenseId.hs
2222
!Cabal/src/Distribution/Simple/Build/Macros/Z.hs
23+
!Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs

Cabal-syntax/src/Distribution/Compat/NonEmptySet.hs

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,43 @@
1-
{-# LANGUAGE CPP #-}
1+
{-# LANGUAGE CPP #-}
22
{-# LANGUAGE DeriveDataTypeable #-}
3-
module Distribution.Compat.NonEmptySet (
4-
NonEmptySet,
3+
4+
module Distribution.Compat.NonEmptySet
5+
( NonEmptySet
6+
57
-- * Construction
6-
singleton,
8+
, singleton
9+
710
-- * Insertion
8-
insert,
11+
, insert
12+
913
-- * Deletion
10-
delete,
14+
, delete
15+
1116
-- * Conversions
12-
toNonEmpty,
13-
fromNonEmpty,
14-
toList,
15-
toSet,
17+
, toNonEmpty
18+
, fromNonEmpty
19+
, toList
20+
, toSet
21+
1622
-- * Query
17-
member,
23+
, member
24+
1825
-- * Map
19-
map,
20-
) where
26+
, map
27+
) where
2128

2229
import Prelude (Bool (..), Eq, Maybe (..), Ord (..), Read, Show (..), String, error, otherwise, return, showParen, showString, ($), (++), (.))
2330

24-
import Control.DeepSeq (NFData (..))
25-
import Data.Data (Data)
31+
import Control.DeepSeq (NFData (..))
32+
import Data.Data (Data)
2633
import Data.List.NonEmpty (NonEmpty (..))
27-
import Data.Semigroup (Semigroup (..))
28-
import Data.Typeable (Typeable)
34+
import Data.Semigroup (Semigroup (..))
35+
import Data.Typeable (Typeable)
2936

3037
import qualified Data.Foldable as F
31-
import qualified Data.Set as Set
38+
import qualified Data.Set as Set
3239

33-
import Distribution.Compat.Binary (Binary (..))
40+
import Distribution.Compat.Binary (Binary (..))
3441
import Distribution.Utils.Structured
3542

3643
#if MIN_VERSION_binary(0,6,0)
@@ -48,40 +55,43 @@ newtype NonEmptySet a = NES (Set.Set a)
4855
-------------------------------------------------------------------------------
4956

5057
instance Show a => Show (NonEmptySet a) where
51-
showsPrec d s = showParen (d > 10)
52-
$ showString "fromNonEmpty "
58+
showsPrec d s =
59+
showParen (d > 10) $
60+
showString "fromNonEmpty "
5361
. showsPrec 11 (toNonEmpty s)
5462

63+
{- FOURMOLU_DISABLE -}
5564
instance Binary a => Binary (NonEmptySet a) where
56-
put (NES s) = put s
57-
get = do
58-
xs <- get
59-
if Set.null xs
65+
put (NES s) = put s
66+
get = do
67+
xs <- get
68+
if Set.null xs
6069
#if MIN_VERSION_binary(0,6,0)
61-
then empty
70+
then empty
6271
#else
63-
then fail "NonEmptySet: empty"
72+
then fail "NonEmptySet: empty"
6473
#endif
65-
else return (NES xs)
74+
else return (NES xs)
75+
{- FOURMOLU_ENABLE -}
6676

6777
instance Structured a => Structured (NonEmptySet a) where
68-
structure = containerStructure
78+
structure = containerStructure
6979

7080
instance NFData a => NFData (NonEmptySet a) where
71-
rnf (NES x) = rnf x
81+
rnf (NES x) = rnf x
7282

7383
-- | Note: there aren't @Monoid@ instance.
7484
instance Ord a => Semigroup (NonEmptySet a) where
75-
NES x <> NES y = NES (Set.union x y)
85+
NES x <> NES y = NES (Set.union x y)
7686

7787
instance F.Foldable NonEmptySet where
78-
foldMap f (NES s) = F.foldMap f s
79-
foldr f z (NES s) = F.foldr f z s
88+
foldMap f (NES s) = F.foldMap f s
89+
foldr f z (NES s) = F.foldr f z s
8090

8191
#if MIN_VERSION_base(4,8,0)
82-
toList = toList
83-
null _ = False
84-
length (NES s) = F.length s
92+
toList = toList
93+
null _ = False
94+
length (NES s) = F.length s
8595
#endif
8696

8797
-------------------------------------------------------------------------------
@@ -104,8 +114,8 @@ insert x (NES xs) = NES (Set.insert x xs)
104114

105115
delete :: Ord a => a -> NonEmptySet a -> Maybe (NonEmptySet a)
106116
delete x (NES xs)
107-
| Set.null res = Nothing
108-
| otherwise = Just (NES xs)
117+
| Set.null res = Nothing
118+
| otherwise = Just (NES xs)
109119
where
110120
res = Set.delete x xs
111121

@@ -118,8 +128,8 @@ fromNonEmpty (x :| xs) = NES (Set.fromList (x : xs))
118128

119129
toNonEmpty :: NonEmptySet a -> NonEmpty a
120130
toNonEmpty (NES s) = case Set.toList s of
121-
[] -> panic "toNonEmpty"
122-
x:xs -> x :| xs
131+
[] -> panic "toNonEmpty"
132+
x : xs -> x :| xs
123133

124134
toList :: NonEmptySet a -> [a]
125135
toList (NES s) = Set.toList s
@@ -138,6 +148,7 @@ member x (NES xs) = Set.member x xs
138148
-- Map
139149
-------------------------------------------------------------------------------
140150

151+
{- FOURMOLU_DISABLE -}
141152
map
142153
:: ( Ord b
143154
#if !MIN_VERSION_containers(0,5,2)
@@ -146,6 +157,7 @@ map
146157
)
147158
=> (a -> b) -> NonEmptySet a -> NonEmptySet b
148159
map f (NES x) = NES (Set.map f x)
160+
{- FOURMOLU_ENABLE -}
149161

150162
-------------------------------------------------------------------------------
151163
-- Internal

0 commit comments

Comments
 (0)