on master help sign in
Comma-separated SPECIALIZE types
fd4fa7fVladislav Zavialov
data/examples/declaration/signature/specialize/specialize-out.hs+10−1
@@ -11,5 +11,14 @@ baz :: Num a => a -> a
11baz = id
11baz = id
12{-# SPECIALIZE [~2] baz
12{-# SPECIALIZE [~2] baz
13 :: Int
13 :: Int
14− -> Int
14+ -> Int
15 #-}
15 #-}
16+
17+{-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
18+{-# SPECIALIZE fits13Bits
19+ :: Int
20+ -> Bool
21+ , Integer -> Bool
22+ #-}
23+fits13Bits :: Integral a => a -> Bool
24+fits13Bits x = x >= -4096 && x < 4096
data/examples/declaration/signature/specialize/specialize.hs+8
@@ -14,3 +14,11 @@ baz = id
14{-# SPECIALIZE [~2] baz
14{-# SPECIALIZE [~2] baz
15 :: Int
15 :: Int
16 -> Int #-}
16 -> Int #-}
17+
18+{-# SPECIALIZE fits13Bits :: Int -> Bool, Integer -> Bool #-}
19+{-# SPECIALIZE fits13Bits
20+ :: Int
21+ -> Bool
22+ , Integer -> Bool #-}
23+fits13Bits :: Integral a => a -> Bool
24+fits13Bits x = x >= -4096 && x < 4096
src/Ormolu/Printer/Meat/Declaration/Signature.hs+1−4
@@ -125,10 +125,7 @@ p_specSig name ts InlinePragma {..} = pragmaBraces $ do
125 breakpoint
125 breakpoint
126 inci $ do
126 inci $ do
127 txt ":: "
127 txt ":: "
128− -- XXX Not at all sure why ts is a list of @LHsSigType GhcPs@ things, it
129− -- appears that we only can give one type to specialize to per pragma.
130− -- Maybe I'm mistaken.
131− located (hsib_body (head ts)) p_hsType
128+ velt (withSep comma (located' p_hsType) (hsib_body <$> ts))
132
129
133p_activation :: Activation -> R ()
130p_activation :: Activation -> R ()
134p_activation = \case
131p_activation = \case