on master help sign in
Comma-separated SPECIALIZE types
commitfd4fa7f33edf100903f8c459143ace5d3d8abc1c authorVladislav Zavialov <vlad.z.4096@gmail.com> dateFri 12 Jul 2019, 01:43 (7 years ago) parent984e4b6
3 files changed+19−5
data/examples/declaration/signature/specialize/specialize-out.hs+10−1 data/examples/declaration/signature/specialize/specialize.hs+8 src/Ormolu/Printer/Meat/Declaration/Signature.hs+1−4
data/examples/declaration/signature/specialize/specialize-out.hs+10−1
@@ -11,5 +11,14 @@ baz :: Num a => a -> a
1111baz = id
1212{-# SPECIALIZE [~2] baz
1313 :: Int
14− -> Int
14+ -> Int
1515 #-}
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
1414{-# SPECIALIZE [~2] baz
1515 :: Int
1616 -> 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
125125 breakpoint
126126 inci $ do
127127 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))
132129
133130p_activation :: Activation -> R ()
134131p_activation = \case