Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
* Now `.ormolu` fixity override files can use both LF and CRLF line endings.
[PR 969](https://github.com/tweag/ormolu/pull/969).

* Normalize parentheses around constraints. [Issue
264](https://github.com/tweag/ormolu/issues/264).

## Ormolu 0.5.2.0

* Eliminated the `fixity-th` Cabal flag because it caused issues on GHC 9.4 as
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ module Main where
class Foo a where
-- | Foo
foo :: a -> String
default foo :: Show a => a -> String
default foo :: (Show a) => a -> String
foo = show
2 changes: 1 addition & 1 deletion data/examples/declaration/class/super-classes-out.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Foo a

class Foo a => Bar a
class (Foo a) => Bar a

class
(Foo a, Bar a) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

data Foo
= forall a. MkFoo a (a -> Bool)
| forall a. Eq a => MkBar a
| forall a. (Eq a) => MkBar a

data Bar
= forall x y.
Expand Down
2 changes: 1 addition & 1 deletion data/examples/declaration/data/existential-out.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

data Foo = forall a. MkFoo a (a -> Bool)

data Bar = forall a b. a + b => Bar a b
data Bar = forall a b. (a + b) => Bar a b
2 changes: 1 addition & 1 deletion data/examples/declaration/instance/contexts-out.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
instance Eq a => Eq [a] where (==) _ _ = False
instance (Eq a) => Eq [a] where (==) _ _ = False

instance
( Ord a,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
instance Num a => Num (Diff a) where
instance (Num a) => Num (Diff a) where
D u dudx + D v dvdx = D (u + v) (dudx + dvdx)
D u dudx - D v dvdx = D (u - v) (dudx - dvdx)
D u dudx * D v dvdx = D (u * v) (u * dvdx + v * dudx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ instance (Eq a) => Eq (Foo a) where

instance (Num r, V.Vector v r, Factored m r) => Num (VT v m r) where
{-# SPECIALIZE instance
( Factored m Int => Num (VT U.Vector m Int)
( (Factored m Int) => Num (VT U.Vector m Int)
)
#-}
VT x + VT y = VT $ V.zipWith (+) x y
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
foo :: Num a => a -> a
foo :: (Num a) => a -> a
foo = id
{-# SPECIALIZE foo :: Int -> Int #-}
{-# SPECIALIZE INLINE foo :: Float -> Float #-}

{-# SPECIALIZE NOINLINE [2] bar :: Int -> Int #-}
bar :: Num a => a -> a
bar :: (Num a) => a -> a
bar = id

baz :: Num a => a -> a
baz :: (Num a) => a -> a
baz = id
{-# SPECIALIZE [~2] baz ::
Int ->
Expand All @@ -20,5 +20,5 @@ baz = id
Bool,
Integer -> Bool
#-}
fits13Bits :: Integral a => a -> Bool
fits13Bits :: (Integral a) => a -> Bool
fits13Bits x = x >= -4096 && x < 4096
2 changes: 1 addition & 1 deletion data/examples/declaration/signature/type/unicode-out.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{-# LANGUAGE UnicodeSyntax #-}

foo :: forall a. Show a => a -> String
foo :: forall a. (Show a) => a -> String
foo = const ()
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ wrapError ::
forall outertag innertag t outer inner m a.
( forall x. Coercible (t m x) (m x),
forall m'.
HasCatch outertag outer m' =>
(HasCatch outertag outer m') =>
HasCatch innertag inner (t m'),
HasCatch outertag outer m
) =>
(forall m'. HasCatch innertag inner m' => m' a) ->
(forall m'. (HasCatch innertag inner m') => m' a) ->
m a
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ magnify ::
forall outertag innertag t outer inner m a.
( forall x. Coercible (t m x) (m x),
forall m'.
HasReader outertag outer m' =>
(HasReader outertag outer m') =>
HasReader innertag inner (t m'),
HasReader outertag outer m
) =>
(forall m'. HasReader innertag inner m' => m' a) ->
(forall m'. (HasReader innertag inner m') => m' a) ->
m a
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inlineComment =
() -> undefined
in go

implicitParams :: HasCallStack => Int
implicitParams :: (HasCallStack) => Int
implicitParams =
let ?cs = ?callstack
in foo cs
Expand Down
4 changes: 2 additions & 2 deletions data/examples/other/argument-comment-out.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ foo ::
foo _ = True

foo ::
Foo a =>
(Foo a) =>
-- | Foo
Int ->
Int
foo ::
Foo a =>
(Foo a) =>
-- | Foo
Int ->
Int
2 changes: 1 addition & 1 deletion data/examples/other/cpp/separation-0a-out.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE CPP #-}

instance Stream s => Monad (ParsecT e s m) where
instance (Stream s) => Monad (ParsecT e s m) where
return = pure
(>>=) = pBind
#if !(MIN_VERSION_base(4,13,0))
Expand Down
2 changes: 1 addition & 1 deletion data/examples/other/cpp/separation-0b-out.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{-# LANGUAGE CPP #-}

instance Stream s => Monad (ParsecT e s m) where
instance (Stream s) => Monad (ParsecT e s m) where
return = pure
(>>=) = pBind
#if !(MIN_VERSION_base(4,13,0))
Expand Down
34 changes: 20 additions & 14 deletions expected-failures/pipes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ src/Pipes/Core.hs
+ -- * ('Control.Monad.>=>'): sequence proxies

-- | Run a self-contained 'Effect', converting it back to the base monad
runEffect :: Monad m => Effect m r -> m r
- runEffect :: Monad m => Effect m r -> m r
+ runEffect :: (Monad m) => Effect m r -> m r
runEffect = go
where
go p = case p of
Expand Down Expand Up @@ -509,11 +510,12 @@ src/Pipes/Core.hs

- 'respond' is the identity of the respond category.
- -}
- respond :: Functor m => a -> Proxy x' x a' a m a'
+ -- | Send a value of type @a@ downstream and block waiting for a reply of type
+ -- @a'@
+ --
+ -- 'respond' is the identity of the respond category.
respond :: Functor m => a -> Proxy x' x a' a m a'
+ respond :: (Functor m) => a -> Proxy x' x a' a m a'
respond a = Respond a Pure
- {-# INLINABLE [1] respond #-}
-
Expand Down Expand Up @@ -542,7 +544,7 @@ src/Pipes/Core.hs
+ --
+ -- ('/>/') is the composition operator of the respond category.
+ (/>/) ::
+ Functor m =>
+ (Functor m) =>
+ (a -> Proxy x' x b' b m a') ->
+ (b -> Proxy x' x c' c m b') ->
+ (a -> Proxy x' x c' c m a')
Expand All @@ -566,7 +568,7 @@ src/Pipes/Core.hs
+ --
+ -- Point-ful version of ('/>/')
+ (//>) ::
+ Functor m =>
+ (Functor m) =>
+ Proxy x' x b' b m a' ->
+ (b -> Proxy x' x c' c m b') ->
+ Proxy x' x c' c m a'
Expand Down Expand Up @@ -754,10 +756,11 @@ src/Pipes/Core.hs

- 'request' is the identity of the request category.
- -}
- request :: Functor m => a' -> Proxy a' a y' y m a
+ -- | Send a value of type @a'@ upstream and block waiting for a reply of type @a@
+ --
+ -- 'request' is the identity of the request category.
request :: Functor m => a' -> Proxy a' a y' y m a
+ request :: (Functor m) => a' -> Proxy a' a y' y m a
request a' = Request a' Pure
- {-# INLINABLE [1] request #-}
-
Expand Down Expand Up @@ -786,7 +789,7 @@ src/Pipes/Core.hs
+ --
+ -- ('\>\') is the composition operator of the request category.
+ (\>\) ::
+ Functor m =>
+ (Functor m) =>
+ (b' -> Proxy a' a y' y m b) ->
+ (c' -> Proxy b' b y' y m c) ->
+ (c' -> Proxy a' a y' y m c)
Expand All @@ -810,7 +813,7 @@ src/Pipes/Core.hs
+ --
+ -- Point-ful version of ('\>\')
+ (>\\) ::
+ Functor m =>
+ (Functor m) =>
+ (b' -> Proxy a' a y' y m b) ->
+ Proxy b' b y' y m c ->
+ Proxy a' a y' y m c
Expand Down Expand Up @@ -965,14 +968,15 @@ src/Pipes/Core.hs

- 'push' is the identity of the push category.
- -}
- push :: Functor m => a -> Proxy a' a a' a m r
+ -- | Forward responses followed by requests
+ --
+ -- @
+ -- 'push' = 'respond' 'Control.Monad.>=>' 'request' 'Control.Monad.>=>' 'push'
+ -- @
+ --
+ -- 'push' is the identity of the push category.
push :: Functor m => a -> Proxy a' a a' a m r
+ push :: (Functor m) => a -> Proxy a' a a' a m r
push = go
where
go a = Respond a (\a' -> Request a' go)
Expand Down Expand Up @@ -1005,7 +1009,7 @@ src/Pipes/Core.hs
+ --
+ -- ('>~>') is the composition operator of the push category.
+ (>~>) ::
+ Functor m =>
+ (Functor m) =>
+ (_a -> Proxy a' a b' b m r) ->
+ (b -> Proxy b' b c' c m r) ->
+ (_a -> Proxy a' a c' c m r)
Expand All @@ -1029,7 +1033,7 @@ src/Pipes/Core.hs
+ --
+ -- Point-ful version of ('>~>')
+ (>>~) ::
+ Functor m =>
+ (Functor m) =>
+ Proxy a' a b' b m r ->
+ (b -> Proxy b' b c' c m r) ->
+ Proxy a' a c' c m r
Expand Down Expand Up @@ -1163,14 +1167,15 @@ src/Pipes/Core.hs

- 'pull' is the identity of the pull category.
- -}
- pull :: Functor m => a' -> Proxy a' a a' a m r
+ -- | Forward requests followed by responses:
+ --
+ -- @
+ -- 'pull' = 'request' 'Control.Monad.>=>' 'respond' 'Control.Monad.>=>' 'pull'
+ -- @
+ --
+ -- 'pull' is the identity of the pull category.
pull :: Functor m => a' -> Proxy a' a a' a m r
+ pull :: (Functor m) => a' -> Proxy a' a a' a m r
pull = go
where
go a' = Request a' (\a -> Respond a go)
Expand Down Expand Up @@ -1203,7 +1208,7 @@ src/Pipes/Core.hs
+ --
+ -- ('>+>') is the composition operator of the pull category.
+ (>+>) ::
+ Functor m =>
+ (Functor m) =>
+ (b' -> Proxy a' a b' b m r) ->
+ (_c' -> Proxy b' b c' c m r) ->
+ (_c' -> Proxy a' a c' c m r)
Expand All @@ -1227,7 +1232,7 @@ src/Pipes/Core.hs
+ --
+ -- Point-ful version of ('>+>')
+ (+>>) ::
+ Functor m =>
+ (Functor m) =>
+ (b' -> Proxy a' a b' b m r) ->
+ Proxy b' b c' c m r ->
+ Proxy a' a c' c m r
Expand Down Expand Up @@ -1306,7 +1311,8 @@ src/Pipes/Core.hs
+ -- @

-- | Switch the upstream and downstream ends
reflect :: Functor m => Proxy a' a b' b m r -> Proxy b b' a a' m r
- reflect :: Functor m => Proxy a' a b' b m r -> Proxy b b' a a' m r
+ reflect :: (Functor m) => Proxy a' a b' b m r -> Proxy b b' a a' m r
reflect = go
where
go p = case p of
Expand Down
6 changes: 3 additions & 3 deletions extract-hackage-info/src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ exitWithMsg t = do
TIO.hPutStrLn stderr t
exitWith (ExitFailure 1)

showT :: Show a => a -> Text
showT :: (Show a) => a -> Text
showT = T.pack . show

readT :: Read a => Text -> a
readT :: (Read a) => Text -> a
readT = read . T.unpack

indentLines :: [Text] -> [Text]
Expand Down Expand Up @@ -390,7 +390,7 @@ extractHackageInfo filePath = do
return result

-- | Limit the number of items in a map.
limitMap :: Ord k => Int -> Map k v -> Map k v
limitMap :: (Ord k) => Int -> Map k v -> Map k v
limitMap n = Map.fromList . take n . Map.toList

data Config = Config
Expand Down
8 changes: 4 additions & 4 deletions src/Ormolu.hs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ import System.FilePath
-- the 'cfgSourceType' field. Autodetection of source type won't happen
-- here, see 'detectSourceType'.
ormolu ::
MonadIO m =>
(MonadIO m) =>
-- | Ormolu configuration
Config RegionIndices ->
-- | Location of source file
Expand Down Expand Up @@ -124,7 +124,7 @@ ormolu cfgWithIndices path originalInput = do
-- the 'cfgSourceType' field. Autodetection of source type won't happen
-- here, see 'detectSourceType'.
ormoluFile ::
MonadIO m =>
(MonadIO m) =>
-- | Ormolu configuration
Config RegionIndices ->
-- | Location of source file
Expand All @@ -140,7 +140,7 @@ ormoluFile cfg path =
-- the 'cfgSourceType' field. Autodetection of source type won't happen
-- here, see 'detectSourceType'.
ormoluStdin ::
MonadIO m =>
(MonadIO m) =>
-- | Ormolu configuration
Config RegionIndices ->
-- | Resulting rendition
Expand All @@ -153,7 +153,7 @@ ormoluStdin cfg =

-- | A wrapper around 'parseModule'.
parseModule' ::
MonadIO m =>
(MonadIO m) =>
-- | Ormolu configuration
Config RegionDeltas ->
-- | Fixity Map for operators
Expand Down
4 changes: 2 additions & 2 deletions src/Ormolu/Diff/ParseResult.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ diffCommentStream (CommentStream cs) (CommentStream cs')
-- * LayoutInfo (brace style) in extension fields
-- * Empty contexts in type classes
-- * Parens around derived type classes
matchIgnoringSrcSpans :: Data a => a -> a -> ParseResultDiff
matchIgnoringSrcSpans :: (Data a) => a -> a -> ParseResultDiff
matchIgnoringSrcSpans a = genericQuery a
where
genericQuery :: GenericQ (GenericQ ParseResultDiff)
Expand Down Expand Up @@ -150,7 +150,7 @@ matchIgnoringSrcSpans a = genericQuery a
unicodeArrowStyleEq (HsLinearArrow _) (castArrow -> Just (HsLinearArrow _)) = Same
unicodeArrowStyleEq (HsExplicitMult _ _ t) (castArrow -> Just (HsExplicitMult _ _ t')) = genericQuery t t'
unicodeArrowStyleEq _ _ = Different []
castArrow :: Typeable a => a -> Maybe (HsArrow GhcPs)
castArrow :: (Typeable a) => a -> Maybe (HsArrow GhcPs)
castArrow = cast
-- LayoutInfo ~ XClassDecl GhcPs tracks brace information
layoutInfoEq :: LayoutInfo -> GenericQ ParseResultDiff
Expand Down
2 changes: 1 addition & 1 deletion src/Ormolu/Fixity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ mergeFixityMaps popularityMap threshold packageMaps =
Map.map
(flip Map.singleton (packageName :| []))
opsMap
maxWith :: Ord b => (a -> b) -> NonEmpty a -> NonEmpty a
maxWith :: (Ord b) => (a -> b) -> NonEmpty a -> NonEmpty a
maxWith f xs = snd $ foldl' comp (f h, h :| []) t
where
h :| t = xs
Expand Down
Loading