PrintDevGraph.hs revision c35969f341eb137848e9c0874503bed8c419cbd2
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaModule : $Header$
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaDescription : pretty printing (parts of) a LibEnv
b43458b4d81f7451112cecbd757f3a05216e7088Kristina SojakovaCopyright : (c) C. Maeder, Uni Bremen 2002-2006
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaLicense : similar to LGPL, see HetCATS/LICENSE.txt or LIZENZ.txt
98890889ffb2e8f6f722b00e265a211f13b5a861Corneliu-Claudiu ProdescuMaintainer : Christian.Maeder@dfki.de
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaStability : provisional
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina SojakovaPortability : non-portable(DevGraph)
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakovapretty printing (parts of) a LibEnv
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova ( prettyLibEnv
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova , prettyHistElem
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova , prettyHistory
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova , dgOriginHeader
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova , dgOriginSpec
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova , dgLinkOriginHeader
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova , dgLinkOriginSpec
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova , dgRuleHeader
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakovaimport qualified Common.Lib.SizedList as SizedList
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakovaimport qualified Common.Lib.Rel as Rel
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakovaimport qualified Common.Lib.Graph as Tree
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakovaimport qualified Data.Map as Map
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakovaimport qualified Data.Set as Set
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaprintTh :: GlobalAnnos -> SIMPLE_ID -> G_theory -> Doc
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaprintTh oga sn g =
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova let ga = removeProblematicListAnnos oga in
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova useGlobalAnnos ga $ pretty ga $+$ prettyGTheorySL g $+$
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova sep [if null (tokStr sn) then Doc.empty else
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova keyword specS <+> sidDoc sn <+> equals, prettyGTheory g]
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaremoveProblematicListAnnos :: GlobalAnnos -> GlobalAnnos
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina SojakovaremoveProblematicListAnnos ga = let
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova is = Map.keysSet $ Rel.toMap $ prec_annos ga
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova la = literal_annos ga
14650c9e129d8dc51ed55b2edc6ec27d9f0f6d00Kristina Sojakova nla = la { list_lit = Map.filterWithKey ( \ li _ ->
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova let (op, cl, cs) = getListBrackets li in
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova Set.null $ Set.filter ( \ (Id ts ics _) ->
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova cs == ics && isPrefixOf op ts && isSuffixOf cl ts) is)
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova $ list_lit la }
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova Result _ (Just lm) = store_literal_map Map.empty $ convertLiteralAnnos nla
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova in ga { literal_annos = nla
ccaa75089b23c0f043cdbd4001cba4e076ca4fd3Kristina Sojakova , literal_map = lm }
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova-- * pretty instances
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian MaedershowXPathComp :: XPathPart -> String
80d2ec8f37d5ddec13c14b17b1bab01e9c94630aChristian MaedershowXPathComp c = case c of
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maeder ElemName s -> s
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova ChildIndex i -> "Spec[" ++ show i ++ "]"
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian MaedershowXPath :: [XPathPart] -> String
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian MaedershowXPath l = case l of
d2786879b4733fd4886a5b654f7c6de1d234f638Kristina Sojakova _ -> concatMap (('/' :) . showXPathComp) l
abd5fc85dc7e19b1614890182436940e922963a4Kristina SojakovashowNodeId :: Node -> String
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina SojakovashowNodeId i = "node " ++ show i
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian Maederinstance Pretty NodeSig where
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina Sojakova pretty (NodeSig n sig) = fsep [ text (showNodeId n) <> colon, pretty sig ]
a669e4685b32ff5ca1bca785eacc5e30a545b010Christian MaederdgOriginSpec :: DGOrigin -> Maybe SIMPLE_ID
b3bacd257ffcdd346b70ab690f03b28ad5f33fdcKristina SojakovadgOriginSpec o = case o of
d71bb9deea089887b4fd829c5b766e7e4de9f204Kristina Sojakova DGInst n -> Just n
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova DGFitView n -> Just n
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina SojakovadgOriginHeader :: DGOrigin -> String
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina SojakovadgOriginHeader o = case o of
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGEmpty -> "empty-spec"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGBasic -> "foreign-basic-spec"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGBasicSpec _ _ -> "basic-spec"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGExtension -> "extension"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGLogicCoercion -> "logic-translation"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGTranslation _ -> "translation"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGUnion -> "union"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGRestriction _ -> "restriction"
abd5fc85dc7e19b1614890182436940e922963a4Kristina Sojakova DGRevealTranslation -> "translation part of a revealing"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGFreeOrCofree v -> map toLower (show v) ++ "-spec"
e8dd447a2aa5fbac10668749dfe4142c05ec3d7dKristina Sojakova DGLocal -> "local-spec"
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina Sojakova DGClosed -> "closed-spec"
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina Sojakova DGLogicQual -> "spec with logic qualifier"
5e35940c3516ccea02caa0450d2b075de0106fa5Kristina Sojakova DGData -> "data-spec"
_ -> Doc.empty
if hasSenKind (const True) l then Doc.empty else text "locally empty"
, if labelHasHiding l then text "has ingoing hiding link" else Doc.empty
Nothing -> Doc.empty
Nothing -> Doc.empty
SeeTarget -> Doc.empty
[ text (dgRuleHeader r) <> if null es then Doc.empty else colon, case r of
[] -> Doc.empty
[(_, _, l)] -> prettyDGLinkLab (const Doc.empty) l
_ -> pretty $ Set.fromList $ map (\ (_, _, l) -> dgl_id l) es]
LeftOpen -> Doc.empty
prettyThmLinkStatus = maybe Doc.empty pretty . thmLinkStatus
None -> Doc.empty
_ -> Doc.empty)
, if dglPending l then text "proof chain incomplete" else Doc.empty
_ -> Doc.empty ]
prettyGr :: Tree.Gr DGNodeLab DGLinkLab -> Doc
EmptyNode _ -> Doc.empty
EmptyNode _ -> Doc.empty
(if null params then Doc.empty else pretty $ map getNode params)
, prettyHistory $ SizedList.reverse $ reverseHistory $ redoHistory dg
prettyHistory = vcat . map prettyHistElem . SizedList.toList