1
1
mirror of https://github.com/google/ormolu.git synced 2024-12-02 23:43:34 +03:00

Comma-separated SPECIALIZE types

This commit is contained in:
Vladislav Zavialov 2019-07-12 01:43:58 +03:00 committed by Mark Karpov
parent 984e4b674f
commit fd4fa7f33e
3 changed files with 19 additions and 5 deletions

View File

@ -11,5 +11,14 @@ baz :: Num a => a -> a
baz = id
{-# SPECIALIZE [~2] baz
:: Int
-> Int
-> Int
#-}
{-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
{-# SPECIALIZE fits13Bits
:: Int
-> Bool
, Integer -> Bool
#-}
fits13Bits :: Integral a => a -> Bool
fits13Bits x = x >= -4096 && x < 4096

View File

@ -14,3 +14,11 @@ baz = id
{-# SPECIALIZE [~2] baz
:: Int
-> Int #-}
{-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
{-# SPECIALIZE fits13Bits
:: Int
-> Bool
, Integer -> Bool #-}
fits13Bits :: Integral a => a -> Bool
fits13Bits x = x >= -4096 && x < 4096

View File

@ -125,10 +125,7 @@ p_specSig name ts InlinePragma {..} = pragmaBraces $ do
breakpoint
inci $ do
txt ":: "
-- XXX Not at all sure why ts is a list of @LHsSigType GhcPs@ things, it
-- appears that we only can give one type to specialize to per pragma.
-- Maybe I'm mistaken.
located (hsib_body (head ts)) p_hsType
velt (withSep comma (located' p_hsType) (hsib_body <$> ts))
p_activation :: Activation -> R ()
p_activation = \case