@@ -27,6 +27,7 @@ p_sigDecl' = \case
2727 ClassOpSig NoExt def names hsib -> p_classOpSig def names hsib
2828 FixSig NoExt sig -> p_fixSig sig
2929 InlineSig NoExt name inlinePragma -> p_inlineSig name inlinePragma
30+ SpecSig NoExt name ts inlinePragma -> p_specSig name ts inlinePragma
3031 _ -> notImplemented "certain types of signature declarations"
3132
3233p_typeSig
@@ -76,13 +77,38 @@ p_inlineSig name InlinePragma {..} = pragmaBraces $ do
7677 NoInline -> "NOINLINE"
7778 NoUserInline -> notImplemented "NoUserInline"
7879 space
79− case inl_act of
80− NeverActive -> return ()
81− AlwaysActive -> return ()
82− ActiveBefore _ n -> do
83− brackets (txt "~" >> atom n)
84− space
85− ActiveAfter _ n -> do
86− brackets (atom n)
87− space
80+ p_activation inl_act
8881 p_rdrName name
82+
83+p_specSig
84+ :: Located RdrName -- ^ Name
85+ -> [LHsSigType GhcPs] -- ^ The types to specialize to
86+ -> InlinePragma -- ^ For specialize inline
87+ -> R ()
88+p_specSig name ts InlinePragma {..} = pragmaBraces $ do
89+ txt "SPECIALIZE"
90+ space
91+ p_activation inl_act
92+ p_rdrName name
93+ breakpoint
94+ inci $ do
95+ txt ":: "
96+ -- XXX Not at all sure why ts is a list of @LHsSigType GhcPs@ things, it
97+ -- appears that we only can give one type to specialize to per pragma.
98+ -- Maybe I'm mistaken.
99+ located (hsib_body (head ts)) p_hsType
100+
101+p_activation :: Activation -> R ()
102+p_activation = \case
103+ NeverActive -> return ()
104+ AlwaysActive -> return ()
105+ ActiveBefore _ n -> do
106+ txt "[~"
107+ atom n
108+ txt "]"
109+ space
110+ ActiveAfter _ n -> do
111+ txt "["
112+ atom n
113+ txt "]"
114+ space