mirror of
https://github.com/google/ormolu.git
synced 2024-09-11 08:05:24 +03:00
Change rendering of type signatures
This commit is contained in:
parent
4cb97b0561
commit
90dc7bf34d
@ -2,8 +2,8 @@
|
||||
|
||||
{-# ANN
|
||||
module
|
||||
( 5 ::
|
||||
Int
|
||||
( 5
|
||||
:: Int
|
||||
)
|
||||
#-}
|
||||
|
||||
|
@ -7,13 +7,13 @@ class Baz a where
|
||||
barbaz (bazbar a)
|
||||
|
||||
-- | Bar baz
|
||||
barbaz ::
|
||||
a -> a
|
||||
barbaz
|
||||
:: a -> a
|
||||
|
||||
-- | Baz bar
|
||||
bazbar ::
|
||||
a ->
|
||||
a
|
||||
bazbar
|
||||
:: a
|
||||
-> a
|
||||
|
||||
-- First comment
|
||||
barbaz a =
|
||||
|
@ -7,7 +7,7 @@ class Foo a where
|
||||
|
||||
-- | Bar
|
||||
class Bar a where
|
||||
bar ::
|
||||
a ->
|
||||
Int
|
||||
bar
|
||||
:: a
|
||||
-> Int
|
||||
bar = const 0
|
||||
|
@ -5,18 +5,18 @@ module Main where
|
||||
-- | Something else.
|
||||
class Bar a where
|
||||
-- | Bar
|
||||
bar ::
|
||||
String ->
|
||||
String ->
|
||||
a
|
||||
bar
|
||||
:: String
|
||||
-> String
|
||||
-> a
|
||||
-- Pointless comment
|
||||
default bar ::
|
||||
( Read a
|
||||
, Semigroup a
|
||||
) =>
|
||||
a ->
|
||||
a ->
|
||||
a
|
||||
default bar
|
||||
:: ( Read a
|
||||
, Semigroup a
|
||||
)
|
||||
=> a
|
||||
-> a
|
||||
-> a
|
||||
-- Even more pointless comment
|
||||
bar
|
||||
a
|
||||
|
@ -16,10 +16,10 @@ class
|
||||
| m -> e s
|
||||
where
|
||||
-- | 'getState' returns state
|
||||
getState ::
|
||||
m s
|
||||
getState
|
||||
:: m s
|
||||
|
||||
-- | 'putState' sets state
|
||||
putState ::
|
||||
s ->
|
||||
m ()
|
||||
putState
|
||||
:: s
|
||||
-> m ()
|
||||
|
@ -4,11 +4,11 @@ class Foo a b where foo :: a -> b
|
||||
|
||||
-- | Something.
|
||||
class Bar a b c d where
|
||||
bar ::
|
||||
a ->
|
||||
b ->
|
||||
c ->
|
||||
d
|
||||
bar
|
||||
:: a
|
||||
-> b
|
||||
-> c
|
||||
-> d
|
||||
|
||||
class -- Before name
|
||||
Baz where
|
||||
|
@ -12,8 +12,8 @@ class
|
||||
e -- Rest
|
||||
f
|
||||
where
|
||||
barbaz ::
|
||||
a -> f
|
||||
bazbar ::
|
||||
e ->
|
||||
f
|
||||
barbaz
|
||||
:: a -> f
|
||||
bazbar
|
||||
:: e
|
||||
-> f
|
||||
|
@ -4,6 +4,6 @@ class Foo (a :: k)
|
||||
|
||||
class
|
||||
Bar
|
||||
( a :: -- Variable
|
||||
* -- Star
|
||||
( a -- Variable
|
||||
:: * -- Star
|
||||
)
|
||||
|
@ -10,17 +10,14 @@ class Bar a where
|
||||
|
||||
class Baz a where
|
||||
-- | Baz
|
||||
baz ::
|
||||
-- | First argument
|
||||
( a
|
||||
, a
|
||||
) ->
|
||||
-- | Second argument
|
||||
a ->
|
||||
-- | Return value
|
||||
a
|
||||
baz
|
||||
:: ( a
|
||||
, a
|
||||
) -- ^ First argument
|
||||
-> a -- ^ Second argument
|
||||
-> a -- ^ Return value
|
||||
|
||||
class BarBaz a where
|
||||
barbaz ::
|
||||
a -> b
|
||||
barbaz
|
||||
:: a -> b
|
||||
bazbar :: b -> a
|
||||
|
@ -5,7 +5,7 @@ data Foo a b where
|
||||
-- | Something
|
||||
Foo :: Foo Int Int
|
||||
-- | Something else
|
||||
Bar ::
|
||||
Foo
|
||||
Char
|
||||
Char
|
||||
Bar
|
||||
:: Foo
|
||||
Char
|
||||
Char
|
||||
|
@ -5,8 +5,8 @@ data Foo = Foo
|
||||
{ -- | Something
|
||||
foo :: Foo Int Int
|
||||
, -- | Something else
|
||||
bar ::
|
||||
Bar
|
||||
Char
|
||||
Char
|
||||
bar
|
||||
:: Bar
|
||||
Char
|
||||
Char
|
||||
}
|
||||
|
@ -5,21 +5,21 @@ module Main where
|
||||
-- | Here goes a comment.
|
||||
data Foo a where
|
||||
-- | 'Foo' is wonderful.
|
||||
Foo ::
|
||||
forall a b.
|
||||
Foo
|
||||
:: forall a b.
|
||||
(Show a, Eq b) => -- foo
|
||||
-- bar
|
||||
a ->
|
||||
b ->
|
||||
Foo 'Int
|
||||
a
|
||||
-> b
|
||||
-> Foo 'Int
|
||||
-- | But 'Bar' is also not too bad.
|
||||
Bar ::
|
||||
Int ->
|
||||
Maybe Text ->
|
||||
Foo 'Bool
|
||||
Bar
|
||||
:: Int
|
||||
-> Maybe Text
|
||||
-> Foo 'Bool
|
||||
-- | So is 'Baz'.
|
||||
Baz ::
|
||||
forall a.
|
||||
a ->
|
||||
Foo 'String
|
||||
Baz
|
||||
:: forall a.
|
||||
a
|
||||
-> Foo 'String
|
||||
(:~>) :: Foo a -> Foo a -> Foo a
|
||||
|
@ -3,13 +3,13 @@ data GADT0 a where
|
||||
|
||||
data GADT1 a where
|
||||
GADT11
|
||||
, GADT12 ::
|
||||
Int ->
|
||||
GADT1 a
|
||||
, GADT12
|
||||
:: Int
|
||||
-> GADT1 a
|
||||
|
||||
data GADT2 a where
|
||||
GADT21
|
||||
, GADT21
|
||||
, GADT22 ::
|
||||
Int ->
|
||||
GADT2 a
|
||||
, GADT22
|
||||
:: Int
|
||||
-> GADT2 a
|
||||
|
@ -3,12 +3,12 @@ module Main where
|
||||
-- | Something.
|
||||
data Foo where
|
||||
Foo :: {fooX :: Int} -> Foo
|
||||
Bar ::
|
||||
{ fooY :: Int
|
||||
, fooBar, fooBaz :: Bool
|
||||
, fooFoo
|
||||
, barBar
|
||||
, bazBaz ::
|
||||
Int
|
||||
} ->
|
||||
Bar
|
||||
:: { fooY :: Int
|
||||
, fooBar, fooBaz :: Bool
|
||||
, fooFoo
|
||||
, barBar
|
||||
, bazBaz
|
||||
:: Int
|
||||
} ->
|
||||
Foo
|
||||
|
@ -6,13 +6,11 @@ module Main where
|
||||
data Foo a where
|
||||
-- | 'Foo' is wonderful.
|
||||
Foo :: forall a b. (Show a, Eq b) => a -> b -> Foo 'Int
|
||||
Bar ::
|
||||
Int ->
|
||||
Text ->
|
||||
-- | But 'Bar' is also not too bad.
|
||||
Foo 'Bool
|
||||
Baz ::
|
||||
forall a.
|
||||
a ->
|
||||
-- | So is 'Baz'.
|
||||
Foo 'String
|
||||
Bar
|
||||
:: Int
|
||||
-> Text
|
||||
-> Foo 'Bool -- ^ But 'Bar' is also not too bad.
|
||||
Baz
|
||||
:: forall a.
|
||||
a
|
||||
-> Foo 'String -- ^ So is 'Baz'.
|
||||
|
@ -10,14 +10,14 @@ data Foo = Foo
|
||||
fooBar, fooBaz :: NonEmpty (Identity Bool)
|
||||
, -- | GagGog
|
||||
fooGag
|
||||
, fooGog ::
|
||||
NonEmpty
|
||||
( Indentity
|
||||
Bool
|
||||
)
|
||||
, fooGog
|
||||
:: NonEmpty
|
||||
( Indentity
|
||||
Bool
|
||||
)
|
||||
, -- | Huh!
|
||||
fooFoo
|
||||
, barBar ::
|
||||
Int
|
||||
, barBar
|
||||
:: Int
|
||||
}
|
||||
deriving (Eq, Show)
|
||||
|
@ -1,7 +1,5 @@
|
||||
data Foo
|
||||
= -- | Bar
|
||||
Bar
|
||||
Field1
|
||||
-- ^ Field 1
|
||||
Field2
|
||||
-- ^ Field 2
|
||||
Field1 -- ^ Field 1
|
||||
Field2 -- ^ Field 2
|
||||
|
@ -1,5 +1,4 @@
|
||||
data X
|
||||
= B
|
||||
!Int
|
||||
-- ^ y
|
||||
!Int -- ^ y
|
||||
C
|
||||
|
@ -2,8 +2,8 @@ foreign export ccall foo :: Int -> IO Int
|
||||
|
||||
-- | 'foreignTomFun' is a very important thing
|
||||
foreign export ccall "tomography"
|
||||
foreignTomFun ::
|
||||
StablePtr Storage {- Storage is bad -} -> TomForegin
|
||||
foreignTomFun
|
||||
:: StablePtr Storage {- Storage is bad -} -> TomForegin
|
||||
|
||||
foreign export {- We can't use capi here -} ccall "dynamic"
|
||||
export_nullaryMeth :: (IO HRESULT) -> IO (Ptr ())
|
||||
|
@ -10,16 +10,15 @@ foreign import stdcall unsafe "boo"
|
||||
boo :: Int -> Text -> IO Array
|
||||
|
||||
foreign import javascript
|
||||
baz ::
|
||||
String ->
|
||||
Int ->
|
||||
IO Foo
|
||||
baz
|
||||
:: String
|
||||
-> Int
|
||||
-> IO Foo
|
||||
|
||||
foreign import {- We use capi here -} capi "pi.h value pi" c_pi :: CDouble
|
||||
|
||||
foreign import stdcall {- This is a bad place for a comment -} "dynamic"
|
||||
dyn_gluBeginSurface ::
|
||||
-- | This 'FunPtr' is extremely dangerous, beware
|
||||
FunPtr (Ptr GLUnurbs -> IO ()) ->
|
||||
Ptr GLUnurbs ->
|
||||
IO ()
|
||||
dyn_gluBeginSurface
|
||||
:: FunPtr (Ptr GLUnurbs -> IO ()) -- ^ This 'FunPtr' is extremely dangerous, beware
|
||||
-> Ptr GLUnurbs
|
||||
-> IO ()
|
||||
|
@ -5,13 +5,13 @@ instance
|
||||
( c -- Bar
|
||||
, d
|
||||
)
|
||||
) =>
|
||||
Read
|
||||
( a -- Baz
|
||||
, b
|
||||
, ( c -- Quux
|
||||
, d
|
||||
)
|
||||
)
|
||||
)
|
||||
=> Read
|
||||
( a -- Baz
|
||||
, b
|
||||
, ( c -- Quux
|
||||
, d
|
||||
)
|
||||
)
|
||||
where
|
||||
readsPrec = undefined
|
||||
|
@ -3,16 +3,16 @@ instance Eq a => Eq [a] where (==) _ _ = False
|
||||
instance
|
||||
( Ord a
|
||||
, Ord b
|
||||
) =>
|
||||
Ord (a, b)
|
||||
)
|
||||
=> Ord (a, b)
|
||||
where
|
||||
compare _ _ = GT
|
||||
|
||||
instance
|
||||
(Show a, Show b) =>
|
||||
Show
|
||||
( a
|
||||
, b
|
||||
)
|
||||
(Show a, Show b)
|
||||
=> Show
|
||||
( a
|
||||
, b
|
||||
)
|
||||
where
|
||||
showsPrec _ _ = showString ""
|
||||
|
@ -2,12 +2,12 @@
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
|
||||
data instance Bar Int a where
|
||||
SameBar ::
|
||||
Bar
|
||||
Int
|
||||
Int
|
||||
SameBar
|
||||
:: Bar
|
||||
Int
|
||||
Int
|
||||
CloseBar :: Bar Int Double
|
||||
OtherBar ::
|
||||
Bar
|
||||
Int
|
||||
a
|
||||
OtherBar
|
||||
:: Bar
|
||||
Int
|
||||
a
|
||||
|
@ -1,10 +1,10 @@
|
||||
{-# LANGUAGE InstanceSigs #-}
|
||||
|
||||
instance Applicative [] where
|
||||
pure ::
|
||||
a ->
|
||||
[a]
|
||||
pure
|
||||
:: a
|
||||
-> [a]
|
||||
pure a = [a]
|
||||
(<*>) ::
|
||||
[a] -> [a] -> [a]
|
||||
(<*>)
|
||||
:: [a] -> [a] -> [a]
|
||||
(<*>) _ _ = []
|
||||
|
@ -5,10 +5,10 @@ instance Eq Int where
|
||||
(==) _ _ = False
|
||||
|
||||
instance Ord Int where
|
||||
compare ::
|
||||
Int ->
|
||||
Int ->
|
||||
Ordering
|
||||
compare
|
||||
:: Int
|
||||
-> Int
|
||||
-> Ordering
|
||||
compare
|
||||
_
|
||||
_ =
|
||||
|
@ -12,11 +12,11 @@
|
||||
|
||||
{-# RULES
|
||||
"rd_tyvs_multiline2" forall
|
||||
( a ::
|
||||
*
|
||||
( a
|
||||
:: *
|
||||
). forall
|
||||
( x ::
|
||||
a
|
||||
( x
|
||||
:: a
|
||||
).
|
||||
id x =
|
||||
x
|
||||
|
@ -6,11 +6,11 @@
|
||||
"fold/build" forall
|
||||
k
|
||||
z
|
||||
( g ::
|
||||
forall b.
|
||||
(a -> b -> b) ->
|
||||
b ->
|
||||
b
|
||||
( g
|
||||
:: forall b.
|
||||
(a -> b -> b)
|
||||
-> b
|
||||
-> b
|
||||
).
|
||||
foldr k z (build g) =
|
||||
g k z
|
||||
|
@ -5,6 +5,6 @@
|
||||
{-# COMPLETE
|
||||
A
|
||||
, B
|
||||
, C ::
|
||||
Foo
|
||||
, C
|
||||
:: Foo
|
||||
#-}
|
||||
|
@ -1,19 +1,19 @@
|
||||
{-# LANGUAGE PatternSynonyms #-}
|
||||
|
||||
pattern Arrow ::
|
||||
Type ->
|
||||
Type ->
|
||||
Type
|
||||
pattern Arrow
|
||||
:: Type
|
||||
-> Type
|
||||
-> Type
|
||||
|
||||
pattern
|
||||
Foo
|
||||
, Bar ::
|
||||
Type -> Type -> Type
|
||||
, Bar
|
||||
:: Type -> Type -> Type
|
||||
|
||||
pattern
|
||||
TypeSignature
|
||||
, FunctionBody
|
||||
, PatternSignature
|
||||
, WarningPragma ::
|
||||
[RdrName] ->
|
||||
HsDecl GhcPs
|
||||
, WarningPragma
|
||||
:: [RdrName]
|
||||
-> HsDecl GhcPs
|
||||
|
@ -9,15 +9,15 @@ bar = id
|
||||
|
||||
baz :: Num a => a -> a
|
||||
baz = id
|
||||
{-# SPECIALIZE [~2] baz ::
|
||||
Int ->
|
||||
Int
|
||||
{-# SPECIALIZE [~2] baz
|
||||
:: Int
|
||||
-> Int
|
||||
#-}
|
||||
|
||||
{-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
|
||||
{-# SPECIALIZE fits13Bits ::
|
||||
Int ->
|
||||
Bool
|
||||
{-# SPECIALIZE fits13Bits
|
||||
:: Int
|
||||
-> Bool
|
||||
, Integer -> Bool
|
||||
#-}
|
||||
fits13Bits :: Integral a => a -> Bool
|
||||
|
@ -1,9 +1,9 @@
|
||||
{-# LANGUAGE StandaloneKindSignatures #-}
|
||||
|
||||
type T ::
|
||||
(k -> Type) ->
|
||||
k ->
|
||||
Type
|
||||
type T
|
||||
:: (k -> Type)
|
||||
-> k
|
||||
-> Type
|
||||
data T m a = MkT (m a) (T Maybe (m a))
|
||||
|
||||
type C1 :: Type -> Constraint
|
||||
|
@ -1,16 +1,16 @@
|
||||
{-# LANGUAGE RankNTypes #-}
|
||||
|
||||
functionName ::
|
||||
(C1, C2, C3, C4, C5) =>
|
||||
a ->
|
||||
b ->
|
||||
( forall a.
|
||||
(C6, C7) =>
|
||||
LongDataTypeName ->
|
||||
a ->
|
||||
AnotherLongDataTypeName ->
|
||||
b ->
|
||||
c
|
||||
) ->
|
||||
(c -> d) ->
|
||||
(a, b, c, d)
|
||||
functionName
|
||||
:: (C1, C2, C3, C4, C5)
|
||||
=> a
|
||||
-> b
|
||||
-> ( forall a.
|
||||
(C6, C7)
|
||||
=> LongDataTypeName
|
||||
-> a
|
||||
-> AnotherLongDataTypeName
|
||||
-> b
|
||||
-> c
|
||||
)
|
||||
-> (c -> d)
|
||||
-> (a, b, c, d)
|
||||
|
@ -1,10 +1,10 @@
|
||||
functionName ::
|
||||
( C1
|
||||
, C2
|
||||
, C3
|
||||
) =>
|
||||
a ->
|
||||
b ->
|
||||
c ->
|
||||
d ->
|
||||
(a, b, c, d)
|
||||
functionName
|
||||
:: ( C1
|
||||
, C2
|
||||
, C3
|
||||
)
|
||||
=> a
|
||||
-> b
|
||||
-> c
|
||||
-> d
|
||||
-> (a, b, c, d)
|
||||
|
@ -1,7 +1,7 @@
|
||||
functionName ::
|
||||
(C1, C2, C3) =>
|
||||
a ->
|
||||
b ->
|
||||
c ->
|
||||
d ->
|
||||
(a, b, c, d)
|
||||
functionName
|
||||
:: (C1, C2, C3)
|
||||
=> a
|
||||
-> b
|
||||
-> c
|
||||
-> d
|
||||
-> (a, b, c, d)
|
||||
|
@ -1,6 +1,6 @@
|
||||
longFunctionName ::
|
||||
a ->
|
||||
b ->
|
||||
c ->
|
||||
d ->
|
||||
(a, b, c, d)
|
||||
longFunctionName
|
||||
:: a
|
||||
-> b
|
||||
-> c
|
||||
-> d
|
||||
-> (a, b, c, d)
|
||||
|
@ -1,16 +1,16 @@
|
||||
functionName ::
|
||||
(C1, C2, C3, C4, C5) =>
|
||||
forall a b c.
|
||||
a ->
|
||||
b ->
|
||||
( LongDataTypeName
|
||||
AnotherLongDataTypeName
|
||||
AnotherLongDataTypeName2
|
||||
AnotherLongDataTypeName3 ->
|
||||
a ->
|
||||
AnotherLongDataTypeName4 ->
|
||||
b ->
|
||||
c
|
||||
) ->
|
||||
(c -> d) ->
|
||||
(a, b, c, d)
|
||||
functionName
|
||||
:: (C1, C2, C3, C4, C5)
|
||||
=> forall a b c.
|
||||
a
|
||||
-> b
|
||||
-> ( LongDataTypeName
|
||||
AnotherLongDataTypeName
|
||||
AnotherLongDataTypeName2
|
||||
AnotherLongDataTypeName3
|
||||
-> a
|
||||
-> AnotherLongDataTypeName4
|
||||
-> b
|
||||
-> c
|
||||
)
|
||||
-> (c -> d)
|
||||
-> (a, b, c, d)
|
||||
|
@ -9,7 +9,7 @@ c = 3
|
||||
|
||||
foo
|
||||
, bar
|
||||
, baz ::
|
||||
Int
|
||||
, baz
|
||||
:: Int
|
||||
bar = 2
|
||||
baz = 3
|
||||
|
@ -16,8 +16,8 @@ type family
|
||||
(a, b)
|
||||
|
||||
type family
|
||||
F a ::
|
||||
* -> *
|
||||
F a
|
||||
:: * -> *
|
||||
where
|
||||
F Int = Double
|
||||
F Bool =
|
||||
|
@ -1,3 +1,2 @@
|
||||
type Elims =
|
||||
-- | eliminations ordered left-to-right.
|
||||
[Elim]
|
||||
[Elim] -- ^ eliminations ordered left-to-right.
|
||||
|
@ -1,4 +1,4 @@
|
||||
type CoerceLocalSig m m' =
|
||||
forall r a.
|
||||
LocalSig m r a ->
|
||||
LocalSig m' r a
|
||||
LocalSig m r a
|
||||
-> LocalSig m' r a
|
||||
|
@ -2,5 +2,5 @@ type A = "foo"
|
||||
|
||||
type B =
|
||||
"foo\
|
||||
\bar" ->
|
||||
()
|
||||
\bar"
|
||||
-> ()
|
||||
|
@ -1,5 +1,5 @@
|
||||
foo = 5 :: Int
|
||||
|
||||
bar =
|
||||
5 ::
|
||||
Int
|
||||
5
|
||||
:: Int
|
||||
|
@ -1,10 +1,10 @@
|
||||
wrapError ::
|
||||
forall outertag innertag t outer inner m a.
|
||||
wrapError
|
||||
:: forall outertag innertag t outer inner m a.
|
||||
( forall x. Coercible (t m x) (m x)
|
||||
, forall m'.
|
||||
HasCatch outertag outer m' =>
|
||||
HasCatch innertag inner (t m')
|
||||
HasCatch outertag outer m'
|
||||
=> HasCatch innertag inner (t m')
|
||||
, HasCatch outertag outer m
|
||||
) =>
|
||||
(forall m'. HasCatch innertag inner m' => m' a) ->
|
||||
m a
|
||||
)
|
||||
=> (forall m'. HasCatch innertag inner m' => m' a)
|
||||
-> m a
|
||||
|
@ -1,10 +1,10 @@
|
||||
magnify ::
|
||||
forall outertag innertag t outer inner m a.
|
||||
magnify
|
||||
:: forall outertag innertag t outer inner m a.
|
||||
( forall x. Coercible (t m x) (m x)
|
||||
, forall m'.
|
||||
HasReader outertag outer m' =>
|
||||
HasReader innertag inner (t m')
|
||||
HasReader outertag outer m'
|
||||
=> HasReader innertag inner (t m')
|
||||
, HasReader outertag outer m
|
||||
) =>
|
||||
(forall m'. HasReader innertag inner m' => m' a) ->
|
||||
m a
|
||||
)
|
||||
=> (forall m'. HasReader innertag inner m' => m' a)
|
||||
-> m a
|
||||
|
@ -6,11 +6,11 @@ sortBy = undefined
|
||||
sort :: (?cmp :: a -> a -> Bool) => [a] -> [a]
|
||||
sort = sortBy ?cmp
|
||||
|
||||
sort' ::
|
||||
( ?cmp ::
|
||||
a -> a -> Bool
|
||||
, ?foo :: Int
|
||||
) =>
|
||||
[a] ->
|
||||
[a]
|
||||
sort'
|
||||
:: ( ?cmp
|
||||
:: a -> a -> Bool
|
||||
, ?foo :: Int
|
||||
)
|
||||
=> [a]
|
||||
-> [a]
|
||||
sort' = sort
|
||||
|
@ -2,6 +2,6 @@ f = do
|
||||
x :: a <- g
|
||||
|
||||
f = do
|
||||
(x, y) ::
|
||||
(a, b) <-
|
||||
(x, y)
|
||||
:: (a, b) <-
|
||||
g
|
||||
|
@ -1,5 +1,5 @@
|
||||
foo x = x :: Int
|
||||
|
||||
bar x =
|
||||
Just x ::
|
||||
Maybe String
|
||||
Just x
|
||||
:: Maybe String
|
||||
|
@ -1,16 +1,13 @@
|
||||
foo ::
|
||||
-- | Documentation
|
||||
Int ->
|
||||
Bool
|
||||
foo
|
||||
:: Int -- ^ Documentation
|
||||
-> Bool
|
||||
foo _ = True
|
||||
|
||||
foo ::
|
||||
Foo a =>
|
||||
-- | Foo
|
||||
Int ->
|
||||
Int
|
||||
foo ::
|
||||
Foo a =>
|
||||
-- | Foo
|
||||
Int ->
|
||||
Int
|
||||
foo
|
||||
:: Foo a
|
||||
=> Int -- ^ Foo
|
||||
-> Int
|
||||
foo
|
||||
:: Foo a
|
||||
=> Int -- ^ Foo
|
||||
-> Int
|
||||
|
@ -1,9 +1,8 @@
|
||||
class Foo a where
|
||||
-- | Foo.
|
||||
foo ::
|
||||
Int ->
|
||||
-- | Something
|
||||
a
|
||||
foo
|
||||
:: Int
|
||||
-> a -- ^ Something
|
||||
|
||||
-- | Bar.
|
||||
bar :: a
|
||||
|
@ -1,7 +1,5 @@
|
||||
foo ::
|
||||
-- | start index
|
||||
Int ->
|
||||
-- | length
|
||||
Int ->
|
||||
t a ->
|
||||
t a
|
||||
foo
|
||||
:: Int -- ^ start index
|
||||
-> Int -- ^ length
|
||||
-> t a
|
||||
-> t a
|
||||
|
@ -1,7 +1,7 @@
|
||||
decompressingPipe ::
|
||||
(PrimMonad m, MonadThrow m, MonadResource m) =>
|
||||
CompressionMethod ->
|
||||
ConduitT ByteString ByteString m ()
|
||||
decompressingPipe
|
||||
:: (PrimMonad m, MonadThrow m, MonadResource m)
|
||||
=> CompressionMethod
|
||||
-> ConduitT ByteString ByteString m ()
|
||||
decompressingPipe Store = C.awaitForever C.yield
|
||||
decompressingPipe Deflate = Z.decompress $ Z.WindowBits (-15)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
decompressingPipe ::
|
||||
(PrimMonad m, MonadThrow m, MonadResource m) =>
|
||||
CompressionMethod ->
|
||||
ConduitT ByteString ByteString m ()
|
||||
decompressingPipe
|
||||
:: (PrimMonad m, MonadThrow m, MonadResource m)
|
||||
=> CompressionMethod
|
||||
-> ConduitT ByteString ByteString m ()
|
||||
decompressingPipe Store = C.awaitForever C.yield
|
||||
decompressingPipe Deflate = Z.decompress $ Z.WindowBits (-15)
|
||||
|
||||
|
@ -7,39 +7,39 @@
|
||||
|
||||
data D
|
||||
= forall
|
||||
( f ::
|
||||
* -> * -> *
|
||||
( f
|
||||
:: * -> * -> *
|
||||
)
|
||||
(x :: *)
|
||||
(y :: *).
|
||||
D (f x y)
|
||||
|
||||
data G where
|
||||
G ::
|
||||
forall
|
||||
( f ::
|
||||
* -> * -> *
|
||||
G
|
||||
:: forall
|
||||
( f
|
||||
:: * -> * -> *
|
||||
)
|
||||
(x :: *)
|
||||
(y :: *).
|
||||
f x y ->
|
||||
G
|
||||
f x y
|
||||
-> G
|
||||
|
||||
f ::
|
||||
forall
|
||||
( f ::
|
||||
* -> * -> *
|
||||
f
|
||||
:: forall
|
||||
( f
|
||||
:: * -> * -> *
|
||||
)
|
||||
(x :: *)
|
||||
(y :: *).
|
||||
f x y ->
|
||||
()
|
||||
f x y
|
||||
-> ()
|
||||
f = const ()
|
||||
|
||||
type family T f x y where
|
||||
forall
|
||||
( f ::
|
||||
* -> * -> *
|
||||
( f
|
||||
:: * -> * -> *
|
||||
)
|
||||
(x :: *)
|
||||
(y :: *).
|
||||
@ -48,8 +48,8 @@ type family T f x y where
|
||||
|
||||
{-# RULES
|
||||
"r" forall
|
||||
( f ::
|
||||
* -> * -> *
|
||||
( f
|
||||
:: * -> * -> *
|
||||
)
|
||||
(x :: *)
|
||||
(y :: *).
|
||||
|
@ -1,11 +1,6 @@
|
||||
tagCloudField ::
|
||||
-- | Destination key
|
||||
String ->
|
||||
-- | Smallest font size, in percent
|
||||
Double ->
|
||||
-- | Biggest font size, in percent
|
||||
Double ->
|
||||
-- | Input tags
|
||||
Tags ->
|
||||
-- | Context
|
||||
Context a
|
||||
tagCloudField
|
||||
:: String -- ^ Destination key
|
||||
-> Double -- ^ Smallest font size, in percent
|
||||
-> Double -- ^ Biggest font size, in percent
|
||||
-> Tags -- ^ Input tags
|
||||
-> Context a -- ^ Context
|
||||
|
@ -22,6 +22,7 @@ module Ormolu.Printer.Combinators
|
||||
newline,
|
||||
inci,
|
||||
inciIf,
|
||||
inci3,
|
||||
located,
|
||||
located',
|
||||
switchLayout,
|
||||
|
@ -20,6 +20,7 @@ module Ormolu.Printer.Internal
|
||||
newline,
|
||||
useRecordDot,
|
||||
inci,
|
||||
inci3,
|
||||
sitcc,
|
||||
Layout (..),
|
||||
enterLayout,
|
||||
@ -382,6 +383,15 @@ inci (R m) = R (local modRC m)
|
||||
{ rcIndent = rcIndent rc + indentStep
|
||||
}
|
||||
|
||||
-- | Increase indentation by 3.
|
||||
inci3 :: R () -> R ()
|
||||
inci3 (R m) = R (local modRC m)
|
||||
where
|
||||
modRC rc =
|
||||
rc
|
||||
{ rcIndent = rcIndent rc + 3
|
||||
}
|
||||
|
||||
-- | Set indentation level for the inner computation equal to current
|
||||
-- column. This makes sure that the entire inner block is uniformly
|
||||
-- \"shifted\" to the right.
|
||||
|
@ -107,13 +107,13 @@ p_conDecl singleConstRec = \case
|
||||
commaDel
|
||||
sep commaDel p_rdrName cs
|
||||
inci $ do
|
||||
space
|
||||
txt "::"
|
||||
let interArgBreak =
|
||||
if hasDocStrings (unLoc con_res_ty)
|
||||
then newline
|
||||
else breakpoint
|
||||
interArgBreak
|
||||
txt "::"
|
||||
space
|
||||
when (unLoc con_forall) $ do
|
||||
p_forallBndrs ForallInvis p_hsTyVarBndr (hsq_explicit con_qvars)
|
||||
interArgBreak
|
||||
@ -151,7 +151,7 @@ p_conDecl singleConstRec = \case
|
||||
PrefixCon xs -> do
|
||||
p_rdrName con_name
|
||||
unless (null xs) breakpoint
|
||||
inci . sitcc $ sep breakpoint (sitcc . located' p_hsTypePostDoc) xs
|
||||
inci . sitcc $ sep breakpoint (sitcc . located' p_hsType) xs
|
||||
RecCon l -> do
|
||||
p_rdrName con_name
|
||||
breakpoint
|
||||
|
@ -56,12 +56,12 @@ p_typeAscription ::
|
||||
LHsSigWcType GhcPs ->
|
||||
R ()
|
||||
p_typeAscription HsWC {..} = inci $ do
|
||||
space
|
||||
txt "::"
|
||||
let t = hsib_body hswc_body
|
||||
if hasDocStrings (unLoc t)
|
||||
then newline
|
||||
else breakpoint
|
||||
txt "::"
|
||||
space
|
||||
located t p_hsType
|
||||
p_typeAscription (XHsWildCardBndrs x) = noExtCon x
|
||||
|
||||
@ -140,10 +140,11 @@ p_specSig name ts InlinePragma {..} = pragmaBraces $ do
|
||||
p_activation inl_act
|
||||
space
|
||||
p_rdrName name
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
inci $ sep commaDel (located' p_hsType . hsib_body) ts
|
||||
inci $ do
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
sep commaDel (located' p_hsType . hsib_body) ts
|
||||
|
||||
p_inlineSpec :: InlineSpec -> R ()
|
||||
p_inlineSpec = \case
|
||||
@ -209,9 +210,9 @@ p_completeSig cs' mty =
|
||||
pragma "COMPLETE" . inci $ do
|
||||
sep commaDel p_rdrName cs
|
||||
forM_ mty $ \ty -> do
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
inci (p_rdrName ty)
|
||||
|
||||
p_sccSig :: Located (IdP GhcPs) -> Maybe (Located StringLiteral) -> R ()
|
||||
@ -227,9 +228,9 @@ p_standaloneKindSig (StandaloneKindSig NoExtField name bndrs) = do
|
||||
inci $ do
|
||||
space
|
||||
p_rdrName name
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
case bndrs of
|
||||
HsIB NoExtField sig -> located sig p_hsType
|
||||
XHsImplicitBndrs x -> noExtCon x
|
||||
|
@ -65,8 +65,9 @@ p_familyResultSigL l =
|
||||
L _ a -> case a of
|
||||
NoSig NoExtField -> Nothing
|
||||
KindSig NoExtField k -> Just $ do
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
located k p_hsType
|
||||
TyVarSig NoExtField bndr -> Just $ do
|
||||
equals
|
||||
|
@ -755,9 +755,9 @@ p_hsExpr' s = \case
|
||||
rupd_flds
|
||||
ExprWithTySig NoExtField x HsWC {hswc_body = HsIB {..}} -> sitcc $ do
|
||||
located x p_hsExpr
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
inci $ located hsib_body p_hsType
|
||||
ExprWithTySig NoExtField _ HsWC {hswc_body = XHsImplicitBndrs x} -> noExtCon x
|
||||
ExprWithTySig NoExtField _ (XHsWildCardBndrs x) -> noExtCon x
|
||||
|
@ -5,7 +5,6 @@
|
||||
-- | Rendering of types.
|
||||
module Ormolu.Printer.Meat.Type
|
||||
( p_hsType,
|
||||
p_hsTypePostDoc,
|
||||
hasDocStrings,
|
||||
p_hsContext,
|
||||
p_hsTyVarBndr,
|
||||
@ -15,6 +14,7 @@ module Ormolu.Printer.Meat.Type
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Bool (bool)
|
||||
import Data.Data (Data)
|
||||
import GHC hiding (isPromoted)
|
||||
import Ormolu.Printer.Combinators
|
||||
@ -24,32 +24,29 @@ import Ormolu.Printer.Operators
|
||||
import Ormolu.Utils
|
||||
|
||||
p_hsType :: HsType GhcPs -> R ()
|
||||
p_hsType t = p_hsType' (hasDocStrings t) PipeStyle t
|
||||
|
||||
p_hsTypePostDoc :: HsType GhcPs -> R ()
|
||||
p_hsTypePostDoc t = p_hsType' (hasDocStrings t) CaretStyle t
|
||||
p_hsType t = p_hsType' False (hasDocStrings t) CaretStyle t
|
||||
|
||||
-- | How to render Haddocks associated with a type.
|
||||
data TypeDocStyle
|
||||
= PipeStyle
|
||||
| CaretStyle
|
||||
|
||||
p_hsType' :: Bool -> TypeDocStyle -> HsType GhcPs -> R ()
|
||||
p_hsType' multilineArgs docStyle = \case
|
||||
p_hsType' :: Bool -> Bool -> TypeDocStyle -> HsType GhcPs -> R ()
|
||||
p_hsType' afterForall multilineArgs docStyle = \case
|
||||
HsForAllTy NoExtField visibility bndrs t -> do
|
||||
p_forallBndrs visibility p_hsTyVarBndr bndrs
|
||||
interArgBreak
|
||||
p_hsTypeR (unLoc t)
|
||||
p_hsTypeRAfterForall (unLoc t)
|
||||
HsQualTy NoExtField qs t -> do
|
||||
located qs p_hsContext
|
||||
space
|
||||
txt "=>"
|
||||
interArgBreak
|
||||
txt "=>"
|
||||
space
|
||||
case unLoc t of
|
||||
HsQualTy {} -> p_hsTypeR (unLoc t)
|
||||
HsFunTy {} -> p_hsTypeR (unLoc t)
|
||||
_ -> located t p_hsTypeR
|
||||
HsTyVar NoExtField p n -> do
|
||||
HsTyVar NoExtField p n -> do -- bool id inci3 solitaryArg
|
||||
case p of
|
||||
IsPromoted -> do
|
||||
txt "'"
|
||||
@ -82,10 +79,10 @@ p_hsType' multilineArgs docStyle = \case
|
||||
txt "@"
|
||||
located kd p_hsType
|
||||
HsFunTy NoExtField x y@(L _ y') -> do
|
||||
located x p_hsType
|
||||
space
|
||||
txt "->"
|
||||
bool id inci3 afterForall (located x p_hsType)
|
||||
interArgBreak
|
||||
txt "->"
|
||||
space
|
||||
case y' of
|
||||
HsFunTy {} -> p_hsTypeR y'
|
||||
_ -> located y p_hsTypeR
|
||||
@ -110,16 +107,16 @@ p_hsType' multilineArgs docStyle = \case
|
||||
parens N (sitcc $ located t p_hsType)
|
||||
HsIParamTy NoExtField n t -> sitcc $ do
|
||||
located n atom
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
inci (located t p_hsType)
|
||||
HsStarTy NoExtField _ -> txt "*"
|
||||
HsKindSig NoExtField t k -> sitcc $ do
|
||||
located t p_hsType
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
inci (located k p_hsType)
|
||||
HsSpliceTy NoExtField splice -> p_hsSplice splice
|
||||
HsDocTy NoExtField t str ->
|
||||
@ -129,7 +126,7 @@ p_hsType' multilineArgs docStyle = \case
|
||||
located t p_hsType
|
||||
CaretStyle -> do
|
||||
located t p_hsType
|
||||
newline
|
||||
space
|
||||
p_hsDocString Caret False str
|
||||
HsBangTy NoExtField (HsSrcBang _ u s) t -> do
|
||||
case u of
|
||||
@ -178,7 +175,8 @@ p_hsType' multilineArgs docStyle = \case
|
||||
if multilineArgs
|
||||
then newline
|
||||
else breakpoint
|
||||
p_hsTypeR = p_hsType' multilineArgs docStyle
|
||||
p_hsTypeR = p_hsType' False multilineArgs docStyle
|
||||
p_hsTypeRAfterForall = p_hsType' True multilineArgs docStyle
|
||||
|
||||
-- | Return 'True' if at least one argument in 'HsType' has a doc string
|
||||
-- attached to it.
|
||||
@ -200,9 +198,9 @@ p_hsTyVarBndr = \case
|
||||
p_rdrName x
|
||||
KindedTyVar NoExtField l k -> parens N . sitcc $ do
|
||||
located l atom
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
inci (located k p_hsType)
|
||||
XTyVarBndr x -> noExtCon x
|
||||
|
||||
@ -232,9 +230,9 @@ p_conDeclField ConDeclField {..} = do
|
||||
commaDel
|
||||
(located' (p_rdrName . rdrNameFieldOcc))
|
||||
cd_fld_names
|
||||
space
|
||||
txt "::"
|
||||
breakpoint
|
||||
txt "::"
|
||||
space
|
||||
sitcc . inci $ p_hsType (unLoc cd_fld_type)
|
||||
p_conDeclField (XConDeclField x) = noExtCon x
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user