Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 33ad064c4b642ed30353356a1d094330 > files > 86

ghc-haddock-devel-2.7.2-3.fc14.x86_64.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://www.cs.york.ac.uk/fp/darcs/hscolour/ -->
<title>src/Haddock/Backends/HaddockDB.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>-----------------------------------------------------------------------------</span>
<a name="line-2"></a><span class='hs-comment'>-- |</span>
<a name="line-3"></a><span class='hs-comment'>-- Module      :  Haddock.Backends.HaddockDB</span>
<a name="line-4"></a><span class='hs-comment'>-- Copyright   :  (c) Simon Marlow 2003</span>
<a name="line-5"></a><span class='hs-comment'>-- License     :  BSD-like</span>
<a name="line-6"></a><span class='hs-comment'>--</span>
<a name="line-7"></a><span class='hs-comment'>-- Maintainer  :  haddock@projects.haskell.org</span>
<a name="line-8"></a><span class='hs-comment'>-- Stability   :  experimental</span>
<a name="line-9"></a><span class='hs-comment'>-- Portability :  portable</span>
<a name="line-10"></a><span class='hs-comment'>-----------------------------------------------------------------------------</span>
<a name="line-11"></a>
<a name="line-12"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Haddock</span><span class='hs-varop'>.</span><span class='hs-conid'>Backends</span><span class='hs-varop'>.</span><span class='hs-conid'>HaddockDB</span> <span class='hs-layout'>(</span><span class='hs-varid'>ppDocBook</span><span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-13"></a>
<a name="line-14"></a><span class='hs-comment'>{-
<a name="line-15"></a>import HaddockTypes
<a name="line-16"></a>import HaddockUtil
<a name="line-17"></a>import HsSyn2
<a name="line-18"></a>
<a name="line-19"></a>import Text.PrettyPrint
<a name="line-20"></a>-}</span>
<a name="line-21"></a>
<a name="line-22"></a><span class='hs-comment'>-----------------------------------------------------------------------------</span>
<a name="line-23"></a><span class='hs-comment'>-- Printing the results in DocBook format</span>
<a name="line-24"></a>
<a name="line-25"></a><a name="ppDocBook"></a><span class='hs-definition'>ppDocBook</span> <span class='hs-keyglyph'>::</span> <span class='hs-varid'>a</span>
<a name="line-26"></a><span class='hs-definition'>ppDocBook</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>error</span> <span class='hs-str'>"not working"</span>
<a name="line-27"></a><span class='hs-comment'>{-
<a name="line-28"></a>ppDocBook :: FilePath -&gt; [(Module, Interface)] -&gt; String
<a name="line-29"></a>ppDocBook odir mods = render (ppIfaces mods)
<a name="line-30"></a>
<a name="line-31"></a>ppIfaces mods
<a name="line-32"></a>  =  text "&lt;!DOCTYPE BOOK PUBLIC \"-//OASIS//DTD DocBook V3.1//EN\" ["
<a name="line-33"></a>  $$ text "]&gt;"
<a name="line-34"></a>  $$ text "&lt;book&gt;"
<a name="line-35"></a>  $$ text "&lt;bookinfo&gt;"
<a name="line-36"></a>  $$ text "&lt;author&gt;&lt;othername&gt;HaskellDoc version 0.0&lt;/othername&gt;&lt;/author&gt;"
<a name="line-37"></a>  $$ text "&lt;/bookinfo&gt;"
<a name="line-38"></a>  $$ text "&lt;article&gt;"
<a name="line-39"></a>  $$ vcat (map do_mod mods)
<a name="line-40"></a>  $$ text "&lt;/article&gt;&lt;/book&gt;"
<a name="line-41"></a>  where
<a name="line-42"></a>     do_mod (Module mod, iface)
<a name="line-43"></a>        =  text "&lt;sect1 id=\"sec-" &lt;&gt; text mod &lt;&gt; text "\"&gt;"
<a name="line-44"></a>        $$ text "&lt;title&gt;&lt;literal&gt;" 
<a name="line-45"></a>	   &lt;&gt; text mod
<a name="line-46"></a>	   &lt;&gt; text "&lt;/literal&gt;&lt;/title&gt;"
<a name="line-47"></a>	$$ text "&lt;indexterm&gt;&lt;primary&gt;&lt;literal&gt;"
<a name="line-48"></a>	   &lt;&gt; text mod
<a name="line-49"></a>	   &lt;&gt; text "&lt;/literal&gt;&lt;/primary&gt;&lt;/indexterm&gt;"
<a name="line-50"></a>	$$ text "&lt;variablelist&gt;"
<a name="line-51"></a>	$$ vcat (map (do_export mod) (eltsFM (iface_decls iface)))
<a name="line-52"></a>	$$ text "&lt;/variablelist&gt;"
<a name="line-53"></a>	$$ text "&lt;/sect1&gt;"
<a name="line-54"></a> 
<a name="line-55"></a>     do_export mod decl | (nm:_) &lt;- declBinders decl
<a name="line-56"></a>	=  text "&lt;varlistentry id=" &lt;&gt; ppLinkId mod nm &lt;&gt; char '&gt;'
<a name="line-57"></a>	$$ text "&lt;term&gt;&lt;literal&gt;" 
<a name="line-58"></a>		&lt;&gt; do_decl decl
<a name="line-59"></a>		&lt;&gt; text "&lt;/literal&gt;&lt;/term&gt;"
<a name="line-60"></a>	$$ text "&lt;listitem&gt;"
<a name="line-61"></a>	$$ text "&lt;para&gt;"
<a name="line-62"></a>	$$ text "&lt;/para&gt;"
<a name="line-63"></a>	$$ text "&lt;/listitem&gt;"
<a name="line-64"></a>	$$ text "&lt;/varlistentry&gt;"
<a name="line-65"></a>     do_export _ _ = empty
<a name="line-66"></a>
<a name="line-67"></a>     do_decl (HsTypeSig _ [nm] ty _) 
<a name="line-68"></a>	=  ppHsName nm &lt;&gt; text " :: " &lt;&gt; ppHsType ty
<a name="line-69"></a>     do_decl (HsTypeDecl _ nm args ty _)
<a name="line-70"></a>	=  hsep ([text "type", ppHsName nm ]
<a name="line-71"></a>		 ++ map ppHsName args 
<a name="line-72"></a>		 ++ [equals, ppHsType ty])
<a name="line-73"></a>     do_decl (HsNewTypeDecl loc ctx nm args con drv _)
<a name="line-74"></a>	= hsep ([text "data", ppHsName nm] -- data, not newtype
<a name="line-75"></a>		++ map ppHsName args
<a name="line-76"></a>		) &lt;+&gt; equals &lt;+&gt; ppHsConstr con -- ToDo: derivings
<a name="line-77"></a>     do_decl (HsDataDecl loc ctx nm args cons drv _)
<a name="line-78"></a>	= hsep ([text "data", {-ToDo: context-}ppHsName nm]
<a name="line-79"></a>	        ++ map ppHsName args)
<a name="line-80"></a>            &lt;+&gt; vcat (zipWith (&lt;+&gt;) (equals : repeat (char '|'))
<a name="line-81"></a>                                    (map ppHsConstr cons))
<a name="line-82"></a>     do_decl (HsClassDecl loc ty fds decl _)
<a name="line-83"></a>	= hsep [text "class", ppHsType ty]
<a name="line-84"></a>     do_decl decl
<a name="line-85"></a>	= empty
<a name="line-86"></a>
<a name="line-87"></a>ppHsConstr :: HsConDecl -&gt; Doc
<a name="line-88"></a>ppHsConstr (HsRecDecl pos name tvs ctxt fieldList maybe_doc) =
<a name="line-89"></a>	 ppHsName name
<a name="line-90"></a>	 &lt;&gt; (braces . hsep . punctuate comma . map ppField $ fieldList)
<a name="line-91"></a>ppHsConstr (HsConDecl pos name tvs ctxt typeList maybe_doc) = 
<a name="line-92"></a>	 hsep (ppHsName name : map ppHsBangType typeList)
<a name="line-93"></a>
<a name="line-94"></a>ppField (HsFieldDecl ns ty doc)
<a name="line-95"></a>   = hsep (punctuate comma (map ppHsName ns) ++
<a name="line-96"></a>	 	[text "::", ppHsBangType ty])
<a name="line-97"></a>
<a name="line-98"></a>ppHsBangType :: HsBangType -&gt; Doc
<a name="line-99"></a>ppHsBangType (HsBangedTy ty) = char '!' &lt;&gt; ppHsType ty
<a name="line-100"></a>ppHsBangType (HsUnBangedTy ty) = ppHsType ty
<a name="line-101"></a>
<a name="line-102"></a>ppHsContext :: HsContext -&gt; Doc
<a name="line-103"></a>ppHsContext []      = empty
<a name="line-104"></a>ppHsContext context = parenList (map (\ (a,b) -&gt; ppHsQName a &lt;+&gt; 
<a name="line-105"></a>					 hsep (map ppHsAType b)) context)
<a name="line-106"></a>
<a name="line-107"></a>ppHsType :: HsType -&gt; Doc
<a name="line-108"></a>ppHsType (HsForAllType Nothing context htype) =
<a name="line-109"></a>     hsep [ ppHsContext context, text "=&gt;", ppHsType htype]
<a name="line-110"></a>ppHsType (HsForAllType (Just tvs) [] htype) =
<a name="line-111"></a>     hsep (text "forall" : map ppHsName tvs ++ text "." : [ppHsType htype])
<a name="line-112"></a>ppHsType (HsForAllType (Just tvs) context htype) =
<a name="line-113"></a>     hsep (text "forall" : map ppHsName tvs ++ text "." : 
<a name="line-114"></a>	   ppHsContext context : text "=&gt;" : [ppHsType htype])
<a name="line-115"></a>ppHsType (HsTyFun a b) = fsep [ppHsBType a, text "-&amp;gt;", ppHsType b]
<a name="line-116"></a>ppHsType (HsTyIP n t)  = fsep [(char '?' &lt;&gt; ppHsName n), text "::", ppHsType t]
<a name="line-117"></a>ppHsType t = ppHsBType t
<a name="line-118"></a>
<a name="line-119"></a>ppHsBType (HsTyApp (HsTyCon (Qual (Module "Prelude") (HsTyClsName (HsSpecial "[]")))) b )
<a name="line-120"></a>  = brackets $ ppHsType b
<a name="line-121"></a>ppHsBType (HsTyApp a b) = fsep [ppHsBType a, ppHsAType b]
<a name="line-122"></a>ppHsBType t = ppHsAType t
<a name="line-123"></a>
<a name="line-124"></a>ppHsAType :: HsType -&gt; Doc
<a name="line-125"></a>ppHsAType (HsTyTuple True l)  = parenList . map ppHsType $ l
<a name="line-126"></a>ppHsAType (HsTyTuple False l) = ubxParenList . map ppHsType $ l
<a name="line-127"></a>-- special case
<a name="line-128"></a>ppHsAType (HsTyApp (HsTyCon (Qual (Module "Prelude") (HsTyClsName (HsSpecial "[]")))) b )
<a name="line-129"></a>  = brackets $ ppHsType b
<a name="line-130"></a>ppHsAType (HsTyVar name) = ppHsName name
<a name="line-131"></a>ppHsAType (HsTyCon name) = ppHsQName name
<a name="line-132"></a>ppHsAType t = parens $ ppHsType t
<a name="line-133"></a>
<a name="line-134"></a>ppHsQName :: HsQName -&gt; Doc
<a name="line-135"></a>ppHsQName (UnQual str)			= ppHsName str
<a name="line-136"></a>ppHsQName n@(Qual (Module mod) str)
<a name="line-137"></a>	 | n == unit_con_name		= ppHsName str
<a name="line-138"></a>	 | isSpecial str 		= ppHsName str
<a name="line-139"></a>	 | otherwise 
<a name="line-140"></a>		=  text "&lt;link linkend=" &lt;&gt; ppLinkId mod str &lt;&gt; char '&gt;'
<a name="line-141"></a>		&lt;&gt; ppHsName str
<a name="line-142"></a>		&lt;&gt; text "&lt;/link&gt;"
<a name="line-143"></a>
<a name="line-144"></a>isSpecial (HsTyClsName id) | HsSpecial _ &lt;- id = True
<a name="line-145"></a>isSpecial (HsVarName id) | HsSpecial _ &lt;- id = True
<a name="line-146"></a>isSpecial _ = False
<a name="line-147"></a>
<a name="line-148"></a>ppHsName :: HsName -&gt; Doc
<a name="line-149"></a>ppHsName (HsTyClsName id) = ppHsIdentifier id
<a name="line-150"></a>ppHsName (HsVarName id) = ppHsIdentifier id
<a name="line-151"></a>
<a name="line-152"></a>ppHsIdentifier :: HsIdentifier -&gt; Doc
<a name="line-153"></a>ppHsIdentifier (HsIdent str)	= text str
<a name="line-154"></a>ppHsIdentifier (HsSymbol str) = text str
<a name="line-155"></a>ppHsIdentifier (HsSpecial str) = text str
<a name="line-156"></a>
<a name="line-157"></a>ppLinkId :: String -&gt; HsName -&gt; Doc
<a name="line-158"></a>ppLinkId mod str
<a name="line-159"></a>  = hcat [char '\"', text mod, char '.', ppHsName str, char '\"']
<a name="line-160"></a>
<a name="line-161"></a>-- -----------------------------------------------------------------------------
<a name="line-162"></a>-- * Misc
<a name="line-163"></a>
<a name="line-164"></a>parenList :: [Doc] -&gt; Doc
<a name="line-165"></a>parenList = parens . fsep . punctuate comma
<a name="line-166"></a>
<a name="line-167"></a>ubxParenList :: [Doc] -&gt; Doc
<a name="line-168"></a>ubxParenList = ubxparens . fsep . punctuate comma
<a name="line-169"></a>
<a name="line-170"></a>ubxparens p = text "(#" &lt;&gt; p &lt;&gt; text "#)"
<a name="line-171"></a>-}</span>
</pre></body>
</html>