keyword libraryS <+> aa') $++$ ad' $++$ ab'
printLibItems :: LogicGraph -> [Annoted LIB_ITEM] -> [Doc]
printLibItems lg is = case is of
i : rs -> prettyLG lg i : printLibItems (case item i of
Logic_decl aa _ -> setLogicName aa lg
instance PrettyLG VIEW_TYPE where
prettyLG = prettyViewType []
prettyViewType :: [a] -> LogicGraph -> VIEW_TYPE -> Doc
prettyViewType ad lg (View_type frm to _) =
sep [ printGroupSpec lg frm <+> keyword toS
, (if null ad then id else (<+> equals))
instance PrettyLG LIB_ITEM where
prettyLG lg li = case li of
Spec_defn si (Genericity aa@(Params pl) ab@(Imported il) _) ac' _ ->
(sa, ac) = if startsWithSemanticAnno las then
(equals <+> annoDoc (head las),
ac' { l_annos = tail las })
x : r = case skipVoidGroup $ item ac of
printExtension lg $ moveAnnos ac e
printUnion lg $ moveAnnos ac u
spid = indexed (iriToStringShortUnsecure si)
if null pl then spid <+> sa
else cat [spid, printPARAMS lg aa <+> sa]
else sep [ cat [spid, printPARAMS lg aa]
, printIMPORTED lg ab <+> sa]
in if null (iriToStringShortUnsecure si) && null pl
then prettyLG lg ac' else
vcat $ (topKey specS <+> vcat [sphead, x]) : r
View_defn si (Genericity aa@(Params pl) ab@(Imported il) _)
if null pl then spid <+> colon
else cat [spid, printPARAMS lg aa <+> colon]
else sep [ cat [spid, printPARAMS lg aa]
, printIMPORTED lg ab <+> colon]
sep [sphead, prettyViewType ad lg vt, ppWithCommas ad]
Entail_defn si et _ -> topKey entailmentS <+>
sep ((structIRI si <+> equals) : case et of
OMSInNetwork i nw s2 _ ->
[ structIRI i <+> keyword inS
Equiv_defn si (Equiv_type as1 as2 _) sp _ -> topKey equivalenceS <+>
sep [structIRI si <+> colon, sep
<+> equals, prettyLG lg sp]
Align_defn si ar vt corresps aSem _ ->
let spid = indexed (iriToStringShortUnsecure si)
Nothing -> spid <+> colon
[spid, printAlignArities alignArities <+> colon ]
sep ([sphead, prettyViewType [] lg vt]
++ if null corresps then []
else [ equals <+> printCorrespondences corresps
, keyword "assuming" <+> keyword (show aSem)])
Module_defn mn mt rs _ ->
let spid = indexed (iriToStringShortUnsecure mn)
Module_type sp1 sp2 _ -> sep
[prettyLG lg sp1, text ofS, prettyLG lg sp2]
sep [sphead, spmt, text forS, pretty rs]
Query_defn qn vs sen spec mt _ -> topKey "query" <+>
fsep ([ structIRI qn <+> equals
, keyword selectS <+> pretty vs
, keyword whereS <+> pretty sen
, keyword inS <+> prettyLG lg spec]
(\ r -> [keyword "along" <+> pretty r]) mt)
Subst_defn sn vt sm _ -> topKey "substitution" <+>
sep [ structIRI sn <+> colon, prettyViewType [] lg vt
Result_defn rn sl sq b _ -> topKey resultS <+>
fsep ([ structIRI rn , ppWithCommas sl
, keyword forS <+> pretty sq]
++ [keyword "%complete" | b])
Arch_spec_defn si ab _ -> topKey archS <+>
fsep [keyword specS, structIRI si <+> equals, prettyLG lg ab]
Unit_spec_defn si ab _ -> topKey unitS <+>
fsep [keyword specS, structIRI si <+> equals, prettyLG lg ab]
Ref_spec_defn si ab _ -> keyword refinementS <+>
fsep [structIRI si <+> equals, prettyLG lg ab]
Network_defn si n _ -> keyword networkS <+>
fsep [structIRI si <+> equals, pretty n]
Download_items l ab _ -> topKey fromS <+>
fsep ((pretty l <+> keyword getS) : prettyDownloadItems ab)
Logic_decl aa _ -> pretty aa
Newlogic_defn nl _ -> pretty nl
Newcomorphism_defn nc _ -> pretty nc
instance PrettyLG OmsOrNetwork where
prettyLG lg s = case s of
MkOms o -> printGroupSpec lg o
prettyDownloadItems :: DownloadItems -> [Doc]
prettyDownloadItems d = case d of
ItemMaps l -> punctuate comma $ map pretty l
UniqueItem i -> [mapsto, structIRI i]
instance PrettyLG GENERICITY where
prettyLG lg (Genericity aa ab _) =
sep [printPARAMS lg aa, printIMPORTED lg ab]
printPARAMS :: LogicGraph -> PARAMS -> Doc
printPARAMS lg (Params aa) = cat $ map (brackets . rmTopKey . prettyLG lg ) aa
printIMPORTED :: LogicGraph -> IMPORTED -> Doc
printIMPORTED lg (Imported aa) = case aa of
_ -> sep [keyword givenS, sepByCommas $ map (printGroupSpec lg) aa]
instance Pretty ALIGN_ARITIES where
pretty = printAlignArities
printAlignArities :: ALIGN_ARITIES -> Doc
printAlignArities (Align_arities f b) =
sep [text alignArityForwardS, printAlignArity f,
text alignArityBackwardS, printAlignArity b]
printAlignArity :: ALIGN_ARITY -> Doc
printAlignArity = text . showAlignArity
printCorrespondences :: [CORRESPONDENCE] -> Doc
printCorrespondences = vsep . punctuate comma . map printCorrespondence
printCorrespondence :: CORRESPONDENCE -> Doc
printCorrespondence Default_correspondence = text "*"
printCorrespondence (Correspondence_block mrref mconf cs) =
map printRelationRef $ maybeToList mrref,
map printConfidence $ maybeToList mconf,
[printCorrespondences cs],
printCorrespondence (Single_correspondence mcid eRef toer mrRef mconf) =
map printRelationRef $ maybeToList mrRef,
map printConfidence $ maybeToList mconf,
map pretty $ maybeToList mcid]
instance Pretty CORRESPONDENCE where
pretty = printCorrespondence
printConfidence :: CONFIDENCE -> Doc
-- "show" should work in [0,1]
printConfidence = text . ('(' :) . (++ ")") . show
printRelationRef :: RELATION_REF -> Doc
printRelationRef rref = case rref of
HasInstance -> keyword "ni"
InstanceOf -> keyword "in"
DefaultRelation -> mapsto
instance Pretty ItemNameMap where
pretty (ItemNameMap a m) = fsep
$ structIRI a : case m of
Just b -> [mapsto, structIRI b]