+\subsection{Foreign function interface declaration}
+%* *
+%************************************************************************
+
+\begin{code}
+data ForeignDecl name =
+ ForeignDecl
+ name
+ ForKind
+ (HsType name)
+ ExtName
+ CallConv
+ SrcLoc
+
+instance (NamedThing name, Outputable name)
+ => Outputable (ForeignDecl name) where
+
+ ppr (ForeignDecl nm imp_exp ty ext_name cconv src_loc)
+ = ptext SLIT("foreign") <+> ppr_imp_exp <+> pprCallConv cconv <+>
+ ppr ext_name <+> ppr_unsafe <+> ppr nm <+> ptext SLIT("::") <+> ppr ty
+ where
+ (ppr_imp_exp, ppr_unsafe) =
+ case imp_exp of
+ FoLabel -> (ptext SLIT("label"), empty)
+ FoExport -> (ptext SLIT("export"), empty)
+ FoImport us
+ | us -> (ptext SLIT("import"), ptext SLIT("unsafe"))
+ | otherwise -> (ptext SLIT("import"), empty)
+
+data ForKind
+ = FoLabel
+ | FoExport
+ | FoImport Bool -- True => unsafe call.
+
+data ExtName
+ = Dynamic
+ | ExtName FAST_STRING (Maybe FAST_STRING)
+
+isDynamic :: ExtName -> Bool
+isDynamic Dynamic = True
+isDynamic _ = False
+
+
+instance Outputable ExtName where
+ ppr Dynamic = ptext SLIT("dynamic")
+ ppr (ExtName nm mb_mod) =
+ case mb_mod of { Nothing -> empty; Just m -> doubleQuotes (ptext m) } <+>
+ doubleQuotes (ptext nm)
+
+\end{code}
+
+%************************************************************************
+%* *