{-# LANGUAGE RankNTypes #-}
module Language.Drasil.Debug.Print where

import           Language.Drasil hiding (symbol)
import qualified Language.Drasil as L (symbol)
import           Database.Drasil
import           Utils.Drasil (stringList)
import qualified Data.Map as Map
import           Control.Lens ((^.), view)
import           Data.List (sort, sortBy)
import           Data.Foldable (foldl')
import           Data.Maybe (fromMaybe)
import           Data.Bifunctor (second)
import           Data.Function (on)
import           Text.PrettyPrint.HughesPJ
import           Language.Drasil.Plain.Print
import           Language.Drasil.Printing.PrintingInformation
import           Prelude hiding ((<>))

import Data.Containers.ListUtils (nubOrd)

-- * Main Function
-- | Gathers all printing functions and creates the debugging tables from them.
printAllDebugInfo :: PrintingInformation -> [Doc]
printAllDebugInfo :: PrintingInformation -> [Doc]
printAllDebugInfo PrintingInformation
pinfo = ((PrintingInformation -> Doc) -> Doc)
-> [PrintingInformation -> Doc] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map
  (Doc -> Doc
cdbSection (Doc -> Doc)
-> ((PrintingInformation -> Doc) -> Doc)
-> (PrintingInformation -> Doc)
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((PrintingInformation -> Doc) -> PrintingInformation -> Doc
forall a b. (a -> b) -> a -> b
$ PrintingInformation
pinfo))
  [ PrintingInformation -> Doc
mkTableReferencedChunks
  , PrintingInformation -> Doc
mkTableDepChunks
  , PrintingInformation -> Doc
mkTableDepReffedChunks
  , PrintingInformation -> Doc
mkTableSymb
  , PrintingInformation -> Doc
mkTableOfTerms
  , PrintingInformation -> Doc
mkTableConcepts
  , PrintingInformation -> Doc
mkTableUnitDefn
  , PrintingInformation -> Doc
mkTableDataDef
  , PrintingInformation -> Doc
mkTableGenDef
  , PrintingInformation -> Doc
mkTableTMod
  , PrintingInformation -> Doc
mkTableIMod
  , PrintingInformation -> Doc
mkTableCI
  , PrintingInformation -> Doc
mkTableSec
  , PrintingInformation -> Doc
mkTableLC
  , PrintingInformation -> Doc
mkTableRef
  , [(UID, String)] -> Doc
renderUsedUIDs ([(UID, String)] -> Doc)
-> (PrintingInformation -> [(UID, String)])
-> PrintingInformation
-> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PrintingInformation -> [(UID, String)]
mkListShowUsedUIDs]

-- * Helpers
-- ** Separators
-- | Debugging table separator.
cdbSection :: Doc -> Doc
cdbSection :: Doc -> Doc
cdbSection Doc
dd = String -> Doc
text (Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
100 Char
'#' String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
"\n") Doc -> Doc -> Doc
$$ Doc
dd Doc -> Doc -> Doc
$$ String -> Doc
text String
"\n"

-- | Header for debugging tables.
header :: Doc -> Doc
header :: Doc -> Doc
header Doc
d = String -> Doc
text (Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
100 Char
'-') Doc -> Doc -> Doc
$$ Doc
d Doc -> Doc -> Doc
$$ String -> Doc
text (Int -> Char -> String
forall a. Int -> a -> [a]
replicate Int
100 Char
'-')

-- ** Table Generators

-- | General function to make the debugging tables. Takes in printing
-- information, a function that extracts a certain field from the printing
-- information, a title, three column headers, and three functions that sort the
-- data from the printing information field into the required display formats
-- (often 'UID's, terms, shortnames, definitions, etc.).
mkTableFromLenses
  :: HasUID a => PrintingInformation
  -> (ChunkDB -> UMap a)
  -> String
  -> [PrintingInformation -> (String, a -> Doc)]
  -> Doc
mkTableFromLenses :: forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses pin :: PrintingInformation
pin@PI { _ckdb :: PrintingInformation -> ChunkDB
_ckdb = ChunkDB
db } ChunkDB -> UMap a
tableLens String
ttle [PrintingInformation -> (String, a -> Doc)]
hsNEs =
  String -> Doc
text String
ttle Doc -> Doc -> Doc
<> Doc
colon
  Doc -> Doc -> Doc
$$ Doc -> Doc
header Doc
hdr
  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat ((a -> Doc) -> [a] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map a -> Doc
col [a]
chunks)
  where
    namedLenses :: [(String, a -> Doc)]
namedLenses = ((PrintingInformation -> (String, a -> Doc)) -> (String, a -> Doc))
-> [PrintingInformation -> (String, a -> Doc)]
-> [(String, a -> Doc)]
forall a b. (a -> b) -> [a] -> [b]
map ((PrintingInformation -> (String, a -> Doc))
-> PrintingInformation -> (String, a -> Doc)
forall a b. (a -> b) -> a -> b
$ PrintingInformation
pin) [PrintingInformation -> (String, a -> Doc)]
hsNEs
    ins :: [Int]
    ins :: [Int]
ins = [Int
1..]

    hdr :: Doc
hdr   = (Doc -> (String, Int) -> Doc) -> Doc -> [(String, Int)] -> Doc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Doc
r (String, Int)
l -> Doc
r Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest (Int
nestNum Int -> Int -> Int
forall a. Num a => a -> a -> a
* (String, Int) -> Int
forall a b. (a, b) -> b
snd (String, Int)
l) (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ (String, Int) -> String
forall a b. (a, b) -> a
fst (String, Int)
l)) (String -> Doc
text String
"UID")       ([String] -> [Int] -> [(String, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip (((String, a -> Doc) -> String) -> [(String, a -> Doc)] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String, a -> Doc) -> String
forall a b. (a, b) -> a
fst [(String, a -> Doc)]
namedLenses) [Int]
ins)
    col :: a -> Doc
col a
a = (Doc -> (a -> Doc, Int) -> Doc) -> Doc -> [(a -> Doc, Int)] -> Doc
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl' (\Doc
r (a -> Doc, Int)
l -> Doc
r Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest (Int
nestNum Int -> Int -> Int
forall a. Num a => a -> a -> a
* (a -> Doc, Int) -> Int
forall a b. (a, b) -> b
snd (a -> Doc, Int)
l) ((a -> Doc, Int) -> a -> Doc
forall a b. (a, b) -> a
fst (a -> Doc, Int)
l a
a)     ) (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ a -> String
forall a. HasUID a => a -> String
showUID a
a) ([a -> Doc] -> [Int] -> [(a -> Doc, Int)]
forall a b. [a] -> [b] -> [(a, b)]
zip (((String, a -> Doc) -> a -> Doc)
-> [(String, a -> Doc)] -> [a -> Doc]
forall a b. (a -> b) -> [a] -> [b]
map (String, a -> Doc) -> a -> Doc
forall a b. (a, b) -> b
snd [(String, a -> Doc)]
namedLenses) [Int]
ins)

    chunks :: [a]
chunks = ((UID, (a, Int)) -> a) -> [(UID, (a, Int))] -> [a]
forall a b. (a -> b) -> [a] -> [b]
map ((a, Int) -> a
forall a b. (a, b) -> a
fst ((a, Int) -> a)
-> ((UID, (a, Int)) -> (a, Int)) -> (UID, (a, Int)) -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (UID, (a, Int)) -> (a, Int)
forall a b. (a, b) -> b
snd) (UMap a -> [(UID, (a, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap a -> [(UID, (a, Int))]) -> UMap a -> [(UID, (a, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap a
tableLens ChunkDB
db)

    nestNum :: Int
nestNum = Int
30

openTerm :: NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm :: forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm PrintingInformation
pinfo = (String
"Term", ChunkDB -> Stage -> SingleLine -> Sentence -> Doc
sentenceDoc (PrintingInformation
pinfo PrintingInformation
-> Getting ChunkDB PrintingInformation ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB PrintingInformation ChunkDB
Lens' PrintingInformation ChunkDB
ckdb) (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg) SingleLine
MultiLine (Sentence -> Doc) -> (a -> Sentence) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NP -> Sentence
forall n. NounPhrase n => n -> Sentence
phraseNP (NP -> Sentence) -> (a -> NP) -> a -> Sentence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting NP a NP -> a -> NP
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting NP a NP
forall c. NamedIdea c => Lens' c NP
Lens' a NP
term)

openSymbol :: HasSymbol a =>PrintingInformation -> (String, a -> Doc)
openSymbol :: forall a. HasSymbol a => PrintingInformation -> (String, a -> Doc)
openSymbol PrintingInformation
pinfo = (String
"Symbol", Symbol -> Doc
symbolDoc (Symbol -> Doc) -> (a -> Symbol) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (a -> Stage -> Symbol) -> Stage -> a -> Symbol
forall a b c. (a -> b -> c) -> b -> a -> c
flip a -> Stage -> Symbol
forall c. HasSymbol c => c -> Stage -> Symbol
L.symbol (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg))

openDefSymbol :: DefinesQuantity s => PrintingInformation -> (String, s -> Doc)
openDefSymbol :: forall s.
DefinesQuantity s =>
PrintingInformation -> (String, s -> Doc)
openDefSymbol PrintingInformation
pinfo = (String
"Symbol Defining", Symbol -> Doc
symbolDoc (Symbol -> Doc) -> (s -> Symbol) -> s -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (QuantityDict -> Stage -> Symbol)
-> Stage -> QuantityDict -> Symbol
forall a b c. (a -> b -> c) -> b -> a -> c
flip QuantityDict -> Stage -> Symbol
forall c. HasSymbol c => c -> Stage -> Symbol
L.symbol (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg) (QuantityDict -> Symbol) -> (s -> QuantityDict) -> s -> Symbol
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting QuantityDict s QuantityDict -> s -> QuantityDict
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting QuantityDict s QuantityDict
forall d. DefinesQuantity d => Getter d QuantityDict
Getter s QuantityDict
defLhs)

openAbbreviation :: Idea a => PrintingInformation -> (String, a -> Doc)
openAbbreviation :: forall a. Idea a => PrintingInformation -> (String, a -> Doc)
openAbbreviation PrintingInformation
_ = (String
"Abbreviation", String -> Doc
text (String -> Doc) -> (a -> String) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe String -> String
forall a. a -> Maybe a -> a
fromMaybe String
"" (Maybe String -> String) -> (a -> Maybe String) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Maybe String
forall c. Idea c => c -> Maybe String
getA)

openDefinition :: Definition a => PrintingInformation -> (String, a -> Doc)
openDefinition :: forall a. Definition a => PrintingInformation -> (String, a -> Doc)
openDefinition PrintingInformation
pinfo = (String
"Definition", ChunkDB -> Stage -> SingleLine -> Sentence -> Doc
sentenceDoc (PrintingInformation
pinfo PrintingInformation
-> Getting ChunkDB PrintingInformation ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB PrintingInformation ChunkDB
Lens' PrintingInformation ChunkDB
ckdb) (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg) SingleLine
OneLine (Sentence -> Doc) -> (a -> Sentence) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting Sentence a Sentence -> a -> Sentence
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting Sentence a Sentence
forall c. Definition c => Lens' c Sentence
Lens' a Sentence
defn)

openUnitSymbol :: HasUnitSymbol a => PrintingInformation -> (String, a -> Doc)
openUnitSymbol :: forall a.
HasUnitSymbol a =>
PrintingInformation -> (String, a -> Doc)
openUnitSymbol PrintingInformation
pinfo = (String
"Unit Symbol", ChunkDB -> Stage -> SingleLine -> Sentence -> Doc
sentenceDoc (PrintingInformation
pinfo PrintingInformation
-> Getting ChunkDB PrintingInformation ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB PrintingInformation ChunkDB
Lens' PrintingInformation ChunkDB
ckdb) (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg) SingleLine
OneLine (Sentence -> Doc) -> (a -> Sentence) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. USymb -> Sentence
Sy (USymb -> Sentence) -> (a -> USymb) -> a -> Sentence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> USymb
forall u. HasUnitSymbol u => u -> USymb
usymb)

openShortName :: HasShortName a => PrintingInformation -> (String, a -> Doc)
openShortName :: forall a.
HasShortName a =>
PrintingInformation -> (String, a -> Doc)
openShortName PrintingInformation
pinfo = (String
"Short Name", ChunkDB -> Stage -> SingleLine -> Sentence -> Doc
sentenceDoc (PrintingInformation
pinfo PrintingInformation
-> Getting ChunkDB PrintingInformation ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB PrintingInformation ChunkDB
Lens' PrintingInformation ChunkDB
ckdb) (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg) SingleLine
OneLine (Sentence -> Doc) -> (a -> Sentence) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShortName -> Sentence
getSentSN (ShortName -> Sentence) -> (a -> ShortName) -> a -> Sentence
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> ShortName
forall s. HasShortName s => s -> ShortName
shortname)

openTitle :: PrintingInformation -> (String, Section -> Doc)
openTitle :: PrintingInformation -> (String, Section -> Doc)
openTitle PrintingInformation
pinfo = (String
"Title", ChunkDB -> Stage -> SingleLine -> Sentence -> Doc
sentenceDoc (PrintingInformation
pinfo PrintingInformation
-> Getting ChunkDB PrintingInformation ChunkDB -> ChunkDB
forall s a. s -> Getting a s a -> a
^. Getting ChunkDB PrintingInformation ChunkDB
Lens' PrintingInformation ChunkDB
ckdb) (PrintingInformation
pinfo PrintingInformation
-> Getting Stage PrintingInformation Stage -> Stage
forall s a. s -> Getting a s a -> a
^. Getting Stage PrintingInformation Stage
Lens' PrintingInformation Stage
stg) SingleLine
MultiLine (Sentence -> Doc) -> (Section -> Sentence) -> Section -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Section -> Sentence
tle)

cntntToStr :: RawContent -> String
cntntToStr :: RawContent -> String
cntntToStr Table {} = String
"Table"
cntntToStr Paragraph {} = String
"Paragraph"
cntntToStr EqnBlock {} = String
"Equation"
cntntToStr DerivBlock {} = String
"Derivation"
cntntToStr Enumeration {} = String
"Enumeration"
cntntToStr Defini {} = String
"Definition or Model"
cntntToStr Figure {} = String
"Figure"
cntntToStr Bib {} = String
"Bibliography"
cntntToStr Graph {} = String
"Graph"
cntntToStr CodeBlock {} = String
"Code"

openContentType :: HasContents s => p -> (String, s -> Doc)
openContentType :: forall s p. HasContents s => p -> (String, s -> Doc)
openContentType p
_ = (String
"Content Type", String -> Doc
text (String -> Doc) -> (s -> String) -> s -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RawContent -> String
cntntToStr (RawContent -> String) -> (s -> RawContent) -> s -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting RawContent s RawContent -> s -> RawContent
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting RawContent s RawContent
forall c. HasContents c => Lens' c RawContent
Lens' s RawContent
accessContents)

openRef :: HasRefAddress a => p -> (String, a -> Doc)
openRef :: forall a p. HasRefAddress a => p -> (String, a -> Doc)
openRef p
_ = (String
"Reference Address", String -> Doc
text (String -> Doc) -> (a -> String) -> a -> Doc
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LblType -> String
getAdd (LblType -> String) -> (a -> LblType) -> a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> LblType
forall b. HasRefAddress b => b -> LblType
getRefAdd)

-- | Makes a table with all symbolic quantities in the SRS.
mkTableSymb :: PrintingInformation -> Doc
mkTableSymb :: PrintingInformation -> Doc
mkTableSymb PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> UMap QuantityDict)
-> String
-> [PrintingInformation -> (String, QuantityDict -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  ChunkDB -> UMap QuantityDict
symbolTable
  String
"Symbol Chunks"
  [PrintingInformation -> (String, QuantityDict -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, QuantityDict -> Doc)
forall a. HasSymbol a => PrintingInformation -> (String, a -> Doc)
openSymbol]

-- | Makes a table with terms in the SRS.
mkTableOfTerms :: PrintingInformation -> Doc
mkTableOfTerms :: PrintingInformation -> Doc
mkTableOfTerms PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> UMap IdeaDict)
-> String
-> [PrintingInformation -> (String, IdeaDict -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  ChunkDB -> UMap IdeaDict
termTable
  String
"Term Chunks"
  [PrintingInformation -> (String, IdeaDict -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, IdeaDict -> Doc)
forall a. Idea a => PrintingInformation -> (String, a -> Doc)
openAbbreviation]

-- | Makes a table with all concepts in the SRS.
mkTableConcepts :: PrintingInformation -> Doc
mkTableConcepts :: PrintingInformation -> Doc
mkTableConcepts PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> UMap ConceptChunk)
-> String
-> [PrintingInformation -> (String, ConceptChunk -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  ChunkDB -> UMap ConceptChunk
defTable
  String
"Concepts"
  [PrintingInformation -> (String, ConceptChunk -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, ConceptChunk -> Doc)
forall a. Definition a => PrintingInformation -> (String, a -> Doc)
openDefinition]

-- | Makes a table with all units used in the SRS.
mkTableUnitDefn :: PrintingInformation -> Doc
mkTableUnitDefn :: PrintingInformation -> Doc
mkTableUnitDefn PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (UnitDefn, Int))
-> String
-> [PrintingInformation -> (String, UnitDefn -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting (Map UID (UnitDefn, Int)) ChunkDB (Map UID (UnitDefn, Int))
-> ChunkDB -> Map UID (UnitDefn, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Map UID (UnitDefn, Int)) ChunkDB (Map UID (UnitDefn, Int))
Lens' ChunkDB (Map UID (UnitDefn, Int))
unitTable)
  String
"Unit Definitions"
  [PrintingInformation -> (String, UnitDefn -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, UnitDefn -> Doc)
forall a.
HasUnitSymbol a =>
PrintingInformation -> (String, a -> Doc)
openUnitSymbol]

-- | Makes a table with all data definitions in the SRS.
mkTableDataDef :: PrintingInformation -> Doc
mkTableDataDef :: PrintingInformation -> Doc
mkTableDataDef PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (DataDefinition, Int))
-> String
-> [PrintingInformation -> (String, DataDefinition -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting
  (Map UID (DataDefinition, Int))
  ChunkDB
  (Map UID (DataDefinition, Int))
-> ChunkDB -> Map UID (DataDefinition, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Map UID (DataDefinition, Int))
  ChunkDB
  (Map UID (DataDefinition, Int))
Lens' ChunkDB (Map UID (DataDefinition, Int))
dataDefnTable)
  String
"Data Definitions"
  [PrintingInformation -> (String, DataDefinition -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, DataDefinition -> Doc)
forall s.
DefinesQuantity s =>
PrintingInformation -> (String, s -> Doc)
openDefSymbol]

-- | Makes a table with all general definitions in the SRS.
mkTableGenDef :: PrintingInformation -> Doc
mkTableGenDef :: PrintingInformation -> Doc
mkTableGenDef PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (GenDefn, Int))
-> String
-> [PrintingInformation -> (String, GenDefn -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting (Map UID (GenDefn, Int)) ChunkDB (Map UID (GenDefn, Int))
-> ChunkDB -> Map UID (GenDefn, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Map UID (GenDefn, Int)) ChunkDB (Map UID (GenDefn, Int))
Lens' ChunkDB (Map UID (GenDefn, Int))
gendefTable)
  String
"General Definitions"
  [PrintingInformation -> (String, GenDefn -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, GenDefn -> Doc)
forall a. Definition a => PrintingInformation -> (String, a -> Doc)
openDefinition]

-- | Makes a table with all theoretical models in the SRS.
mkTableTMod :: PrintingInformation -> Doc
mkTableTMod :: PrintingInformation -> Doc
mkTableTMod PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (TheoryModel, Int))
-> String
-> [PrintingInformation -> (String, TheoryModel -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting
  (Map UID (TheoryModel, Int)) ChunkDB (Map UID (TheoryModel, Int))
-> ChunkDB -> Map UID (TheoryModel, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Map UID (TheoryModel, Int)) ChunkDB (Map UID (TheoryModel, Int))
Lens' ChunkDB (Map UID (TheoryModel, Int))
theoryModelTable)
  String
"Theory Models"
  [PrintingInformation -> (String, TheoryModel -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, TheoryModel -> Doc)
forall a. Definition a => PrintingInformation -> (String, a -> Doc)
openDefinition]

-- | Makes a table with all instance models in the SRS.
mkTableIMod :: PrintingInformation -> Doc
mkTableIMod :: PrintingInformation -> Doc
mkTableIMod PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (InstanceModel, Int))
-> String
-> [PrintingInformation -> (String, InstanceModel -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting
  (Map UID (InstanceModel, Int))
  ChunkDB
  (Map UID (InstanceModel, Int))
-> ChunkDB -> Map UID (InstanceModel, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Map UID (InstanceModel, Int))
  ChunkDB
  (Map UID (InstanceModel, Int))
Lens' ChunkDB (Map UID (InstanceModel, Int))
insmodelTable)
  String
"Instance Models"
  [PrintingInformation -> (String, InstanceModel -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, InstanceModel -> Doc)
forall a. Definition a => PrintingInformation -> (String, a -> Doc)
openDefinition]

-- | Makes a table with all concept instances in the SRS.
mkTableCI :: PrintingInformation -> Doc
mkTableCI :: PrintingInformation -> Doc
mkTableCI PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (ConceptInstance, Int))
-> String
-> [PrintingInformation -> (String, ConceptInstance -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting
  (Map UID (ConceptInstance, Int))
  ChunkDB
  (Map UID (ConceptInstance, Int))
-> ChunkDB -> Map UID (ConceptInstance, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Map UID (ConceptInstance, Int))
  ChunkDB
  (Map UID (ConceptInstance, Int))
Lens' ChunkDB (Map UID (ConceptInstance, Int))
conceptinsTable)
  String
"ConceptInstance"
  [PrintingInformation -> (String, ConceptInstance -> Doc)
forall a. NamedIdea a => PrintingInformation -> (String, a -> Doc)
openTerm, PrintingInformation -> (String, ConceptInstance -> Doc)
forall a.
HasShortName a =>
PrintingInformation -> (String, a -> Doc)
openShortName]

-- | Makes a table with all sections in the SRS.
mkTableSec :: PrintingInformation -> Doc
mkTableSec :: PrintingInformation -> Doc
mkTableSec PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (Section, Int))
-> String
-> [PrintingInformation -> (String, Section -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting (Map UID (Section, Int)) ChunkDB (Map UID (Section, Int))
-> ChunkDB -> Map UID (Section, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting (Map UID (Section, Int)) ChunkDB (Map UID (Section, Int))
Lens' ChunkDB (Map UID (Section, Int))
sectionTable)
  String
"Sections"
  [PrintingInformation -> (String, Section -> Doc)
openTitle, PrintingInformation -> (String, Section -> Doc)
forall a.
HasShortName a =>
PrintingInformation -> (String, a -> Doc)
openShortName]

-- | Makes a table with all labelled content in the SRS.
mkTableLC :: PrintingInformation -> Doc
mkTableLC :: PrintingInformation -> Doc
mkTableLC PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (LabelledContent, Int))
-> String
-> [PrintingInformation -> (String, LabelledContent -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting
  (Map UID (LabelledContent, Int))
  ChunkDB
  (Map UID (LabelledContent, Int))
-> ChunkDB -> Map UID (LabelledContent, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Map UID (LabelledContent, Int))
  ChunkDB
  (Map UID (LabelledContent, Int))
Lens' ChunkDB (Map UID (LabelledContent, Int))
labelledcontentTable)
  String
"LabelledContent"
  [PrintingInformation -> (String, LabelledContent -> Doc)
forall a.
HasShortName a =>
PrintingInformation -> (String, a -> Doc)
openShortName, PrintingInformation -> (String, LabelledContent -> Doc)
forall s p. HasContents s => p -> (String, s -> Doc)
openContentType]

-- | Makes a table with all references in the SRS.
mkTableRef :: PrintingInformation -> Doc
mkTableRef :: PrintingInformation -> Doc
mkTableRef PrintingInformation
pinfo = PrintingInformation
-> (ChunkDB -> Map UID (Reference, Int))
-> String
-> [PrintingInformation -> (String, Reference -> Doc)]
-> Doc
forall a.
HasUID a =>
PrintingInformation
-> (ChunkDB -> UMap a)
-> String
-> [PrintingInformation -> (String, a -> Doc)]
-> Doc
mkTableFromLenses
  PrintingInformation
pinfo
  (Getting
  (Map UID (Reference, Int)) ChunkDB (Map UID (Reference, Int))
-> ChunkDB -> Map UID (Reference, Int)
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting
  (Map UID (Reference, Int)) ChunkDB (Map UID (Reference, Int))
Lens' ChunkDB (Map UID (Reference, Int))
refTable)
  String
"Reference"
  [PrintingInformation -> (String, Reference -> Doc)
forall a p. HasRefAddress a => p -> (String, a -> Doc)
openRef, PrintingInformation -> (String, Reference -> Doc)
forall a.
HasShortName a =>
PrintingInformation -> (String, a -> Doc)
openShortName]

-- | Chunks that depend on other chunks. An empty list means the chunks do not depend on anything.
mkTableDepChunks :: PrintingInformation -> Doc
mkTableDepChunks :: PrintingInformation -> Doc
mkTableDepChunks PI { _ckdb :: PrintingInformation -> ChunkDB
_ckdb = ChunkDB
db } = String -> Doc
text
  String
"Dependent Chunks (the chunks on the left use the chunks on the right in some capacity)"
  Doc -> Doc -> Doc
<> Doc
colon
  Doc -> Doc -> Doc
$$ Doc -> Doc
header (String -> Doc
text String
"UID" Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
nestNum (String -> Doc
text String
"Dependent UIDs"))
  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat (((UID, [UID]) -> Doc) -> [(UID, [UID])] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (UID, [UID]) -> Doc
testIndepLayout [(UID, [UID])]
traceMapUIDs)
  where
    testIndepLayout :: (UID, [UID]) -> Doc
    testIndepLayout :: (UID, [UID]) -> Doc
testIndepLayout (UID
x, [UID]
ys) = String -> Doc
text (UID -> String
forall a. Show a => a -> String
show UID
x) Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
nestNum (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ [UID] -> String
forall a. Show a => a -> String
show [UID]
ys)

    traceMapUIDs :: [(UID, [UID])]
    traceMapUIDs :: [(UID, [UID])]
traceMapUIDs = Map UID [UID] -> [(UID, [UID])]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID [UID] -> [(UID, [UID])])
-> Map UID [UID] -> [(UID, [UID])]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting (Map UID [UID]) ChunkDB (Map UID [UID]) -> Map UID [UID]
forall s a. s -> Getting a s a -> a
^. Getting (Map UID [UID]) ChunkDB (Map UID [UID])
Lens' ChunkDB (Map UID [UID])
traceTable

    nestNum :: Int
nestNum = Int
30

-- | Chunks that are referenced and used by other chunks.
-- Those chunks build on top of the ones listed here.
mkTableReferencedChunks :: PrintingInformation -> Doc
mkTableReferencedChunks :: PrintingInformation -> Doc
mkTableReferencedChunks PI { _ckdb :: PrintingInformation -> ChunkDB
_ckdb = ChunkDB
db } =
  String -> Doc
text String
"Referenced Chunks (other chunks build from these)" Doc -> Doc -> Doc
<> Doc
colon
  Doc -> Doc -> Doc
$$ Doc -> Doc
header (String -> Doc
text String
"UID" Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
nestNum (String -> Doc
text String
"UIDs that use the left UID"))
  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat (((UID, [UID]) -> Doc) -> [(UID, [UID])] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (UID, [UID]) -> Doc
testIsolateLayout [(UID, [UID])]
refbyUIDs)
  where
    testIsolateLayout :: (UID, [UID]) -> Doc
    testIsolateLayout :: (UID, [UID]) -> Doc
testIsolateLayout (UID
x, [UID]
ys) = String -> Doc
text (UID -> String
forall a. Show a => a -> String
show UID
x) Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
nestNum (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ [UID] -> String
forall a. Show a => a -> String
show [UID]
ys)

    refbyUIDs :: [(UID, [UID])]
    refbyUIDs :: [(UID, [UID])]
refbyUIDs = Map UID [UID] -> [(UID, [UID])]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID [UID] -> [(UID, [UID])])
-> Map UID [UID] -> [(UID, [UID])]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting (Map UID [UID]) ChunkDB (Map UID [UID]) -> Map UID [UID]
forall s a. s -> Getting a s a -> a
^. Getting (Map UID [UID]) ChunkDB (Map UID [UID])
Lens' ChunkDB (Map UID [UID])
refbyTable

    nestNum :: Int
nestNum = Int
30

-- | Chunks that use and are used by other chunks.
mkTableDepReffedChunks :: PrintingInformation -> Doc
mkTableDepReffedChunks :: PrintingInformation -> Doc
mkTableDepReffedChunks PI { _ckdb :: PrintingInformation -> ChunkDB
_ckdb = ChunkDB
db } = String -> Doc
text
  String
"Dependent and Referenced Chunks (chunks dependent on middle UIDs and used in the chunks on the right)"
  Doc -> Doc -> Doc
<> Doc
colon
  Doc -> Doc -> Doc
$$ Doc -> Doc
header
    (String -> Doc
text String
"UID"
     Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
nestNum (String -> Doc
text String
"Dependent Chunk")
     Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest (Int
nestNum Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
3) (String -> Doc
text String
"Used-in Chunk"))
  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat (((UID, ([UID], [UID])) -> Doc) -> [(UID, ([UID], [UID]))] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (UID, ([UID], [UID])) -> Doc
traceRefLayout ([(UID, ([UID], [UID]))] -> [Doc])
-> [(UID, ([UID], [UID]))] -> [Doc]
forall a b. (a -> b) -> a -> b
$ Map UID ([UID], [UID]) -> [(UID, ([UID], [UID]))]
forall k a. Map k a -> [(k, a)]
Map.assocs Map UID ([UID], [UID])
combinedMaps)
  where
    traceRefLayout :: (UID, ([UID], [UID])) -> Doc
    traceRefLayout :: (UID, ([UID], [UID])) -> Doc
traceRefLayout (UID, ([UID], [UID]))
x = String -> Doc
text (UID -> String
forall a. Show a => a -> String
show (UID -> String) -> UID -> String
forall a b. (a -> b) -> a -> b
$ (UID, ([UID], [UID])) -> UID
forall a b. (a, b) -> a
fst (UID, ([UID], [UID]))
x)
      Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
nestNum (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ [UID] -> String
forall a. Show a => a -> String
show ([UID] -> String) -> [UID] -> String
forall a b. (a -> b) -> a -> b
$ ([UID], [UID]) -> [UID]
forall a b. (a, b) -> a
fst (([UID], [UID]) -> [UID]) -> ([UID], [UID]) -> [UID]
forall a b. (a -> b) -> a -> b
$ (UID, ([UID], [UID])) -> ([UID], [UID])
forall a b. (a, b) -> b
snd (UID, ([UID], [UID]))
x)
      Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest (Int
nestNum Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
3) (String -> Doc
text (String -> Doc) -> String -> Doc
forall a b. (a -> b) -> a -> b
$ [UID] -> String
forall a. Show a => a -> String
show ([UID] -> String) -> [UID] -> String
forall a b. (a -> b) -> a -> b
$ ([UID], [UID]) -> [UID]
forall a b. (a, b) -> b
snd (([UID], [UID]) -> [UID]) -> ([UID], [UID]) -> [UID]
forall a b. (a -> b) -> a -> b
$ (UID, ([UID], [UID])) -> ([UID], [UID])
forall a b. (a, b) -> b
snd (UID, ([UID], [UID]))
x)

    combinedMaps :: Map UID ([UID], [UID])
combinedMaps =
      (([UID], [UID]) -> ([UID], [UID]) -> ([UID], [UID]))
-> Map UID ([UID], [UID])
-> Map UID ([UID], [UID])
-> Map UID ([UID], [UID])
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith (\([UID], [UID])
x ([UID], [UID])
y -> (([UID], [UID]) -> [UID]
forall a b. (a, b) -> a
fst ([UID], [UID])
x, ([UID], [UID]) -> [UID]
forall a b. (a, b) -> b
snd ([UID], [UID])
y)) Map UID ([UID], [UID])
forall {a}. Map UID ([UID], [a])
traceMapUIDs Map UID ([UID], [UID])
forall {a}. Map UID ([a], [UID])
refByUIDs

    traceMapUIDs :: Map UID ([UID], [a])
traceMapUIDs = [(UID, ([UID], [a]))] -> Map UID ([UID], [a])
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
      ([(UID, ([UID], [a]))] -> Map UID ([UID], [a]))
-> [(UID, ([UID], [a]))] -> Map UID ([UID], [a])
forall a b. (a -> b) -> a -> b
$ ((UID, [UID]) -> (UID, ([UID], [a])))
-> [(UID, [UID])] -> [(UID, ([UID], [a]))]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID
x, [UID]
y) -> (UID
x, ([UID]
y, [])))
      ([(UID, [UID])] -> [(UID, ([UID], [a]))])
-> [(UID, [UID])] -> [(UID, ([UID], [a]))]
forall a b. (a -> b) -> a -> b
$ Map UID [UID] -> [(UID, [UID])]
forall k a. Map k a -> [(k, a)]
Map.assocs
      (Map UID [UID] -> [(UID, [UID])])
-> Map UID [UID] -> [(UID, [UID])]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting (Map UID [UID]) ChunkDB (Map UID [UID]) -> Map UID [UID]
forall s a. s -> Getting a s a -> a
^. Getting (Map UID [UID]) ChunkDB (Map UID [UID])
Lens' ChunkDB (Map UID [UID])
traceTable

    refByUIDs :: Map UID ([a], [UID])
refByUIDs = [(UID, ([a], [UID]))] -> Map UID ([a], [UID])
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
      ([(UID, ([a], [UID]))] -> Map UID ([a], [UID]))
-> [(UID, ([a], [UID]))] -> Map UID ([a], [UID])
forall a b. (a -> b) -> a -> b
$ ((UID, [UID]) -> (UID, ([a], [UID])))
-> [(UID, [UID])] -> [(UID, ([a], [UID]))]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID
x, [UID]
y) -> (UID
x, ([], [UID]
y)))
      ([(UID, [UID])] -> [(UID, ([a], [UID]))])
-> [(UID, [UID])] -> [(UID, ([a], [UID]))]
forall a b. (a -> b) -> a -> b
$ Map UID [UID] -> [(UID, [UID])]
forall k a. Map k a -> [(k, a)]
Map.assocs
      (Map UID [UID] -> [(UID, [UID])])
-> Map UID [UID] -> [(UID, [UID])]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting (Map UID [UID]) ChunkDB (Map UID [UID]) -> Map UID [UID]
forall s a. s -> Getting a s a -> a
^. Getting (Map UID [UID]) ChunkDB (Map UID [UID])
Lens' ChunkDB (Map UID [UID])
refbyTable

    nestNum :: Int
nestNum = Int
30

-- ** 'UID' Manipulation
-- | Creates a table of all UIDs and their "highest" recorded level of information. See 'mkListShowUsedUIDs'
-- for more details.
renderUsedUIDs :: [(UID, String)] -> Doc
renderUsedUIDs :: [(UID, String)] -> Doc
renderUsedUIDs [(UID, String)]
chs = Doc -> Doc
header (String -> Doc
text String
"UIDs" Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
40 (String -> Doc
text String
"Associated Chunks"))
  Doc -> Doc -> Doc
$$ [Doc] -> Doc
vcat (((UID, String) -> Doc) -> [(UID, String)] -> [Doc]
forall a b. (a -> b) -> [a] -> [b]
map (UID, String) -> Doc
forall {a}. Show a => (a, String) -> Doc
renderUsedUID [(UID, String)]
chs)
  where
    renderUsedUID :: (a, String) -> Doc
renderUsedUID (a
u, String
chks) = String -> Doc
text (a -> String
forall a. Show a => a -> String
show a
u) Doc -> Doc -> Doc
$$ Int -> Doc -> Doc
nest Int
40 (String -> Doc
text String
chks)

-- | For the last section of the log output. Shows which chunk UID is being used at which stage.
-- Note that chunks used at a "higher stage" (like 'Concept's and 'QuantityDict's) will still be built off of the
-- more basic types (like 'IdeaDict's), they are just not explicitly used in that manner.
-- Also, some chunks may have been "downgraded" when put into the database (for example, mapping a
-- 'QuantityDict' wrapper onto things like Constrained and Unital chunks happens often).
mkListShowUsedUIDs :: PrintingInformation -> [(UID, String)]
mkListShowUsedUIDs :: PrintingInformation -> [(UID, String)]
mkListShowUsedUIDs PI { _ckdb :: PrintingInformation -> ChunkDB
_ckdb = ChunkDB
db } = ((UID, String) -> (UID, String) -> Ordering)
-> [(UID, String)] -> [(UID, String)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (UID -> UID -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (UID -> UID -> Ordering)
-> ((UID, String) -> UID)
-> (UID, String)
-> (UID, String)
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (UID, String) -> UID
forall a b. (a, b) -> a
fst)
  ([(UID, String)] -> [(UID, String)])
-> [(UID, String)] -> [(UID, String)]
forall a b. (a -> b) -> a -> b
$ ((UID, [String]) -> (UID, String))
-> [(UID, [String])] -> [(UID, String)]
forall a b. (a -> b) -> [a] -> [b]
map (([String] -> String) -> (UID, [String]) -> (UID, String)
forall b c a. (b -> c) -> (a, b) -> (a, c)
forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second [String] -> String
stringList)
  ([(UID, [String])] -> [(UID, String)])
-> [(UID, [String])] -> [(UID, String)]
forall a b. (a -> b) -> a -> b
$ Map UID [String] -> [(UID, [String])]
forall k a. Map k a -> [(k, a)]
Map.toList
  (Map UID [String] -> [(UID, [String])])
-> Map UID [String] -> [(UID, [String])]
forall a b. (a -> b) -> a -> b
$ ([String] -> [String] -> [String])
-> [(UID, [String])] -> Map UID [String]
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
(++)
  ([(UID, [String])] -> Map UID [String])
-> [(UID, [String])] -> Map UID [String]
forall a b. (a -> b) -> a -> b
$ ((UID, (QuantityDict, Int)) -> (UID, [String]))
-> [(UID, (QuantityDict, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (QuantityDict, Int))
x -> ((UID, (QuantityDict, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (QuantityDict, Int))
x, [String
"QuantityDict"])) (UMap QuantityDict -> [(UID, (QuantityDict, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap QuantityDict -> [(UID, (QuantityDict, Int))])
-> UMap QuantityDict -> [(UID, (QuantityDict, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap QuantityDict
symbolTable ChunkDB
db)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (IdeaDict, Int)) -> (UID, [String]))
-> [(UID, (IdeaDict, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (IdeaDict, Int))
x -> ((UID, (IdeaDict, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (IdeaDict, Int))
x, [String
"IdeaDict"])) (UMap IdeaDict -> [(UID, (IdeaDict, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap IdeaDict -> [(UID, (IdeaDict, Int))])
-> UMap IdeaDict -> [(UID, (IdeaDict, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap IdeaDict
termTable ChunkDB
db)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (ConceptChunk, Int)) -> (UID, [String]))
-> [(UID, (ConceptChunk, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (ConceptChunk, Int))
x -> ((UID, (ConceptChunk, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (ConceptChunk, Int))
x, [String
"ConceptChunk"])) (UMap ConceptChunk -> [(UID, (ConceptChunk, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap ConceptChunk -> [(UID, (ConceptChunk, Int))])
-> UMap ConceptChunk -> [(UID, (ConceptChunk, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap ConceptChunk
defTable ChunkDB
db)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (UnitDefn, Int)) -> (UID, [String]))
-> [(UID, (UnitDefn, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (UnitDefn, Int))
x -> ((UID, (UnitDefn, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (UnitDefn, Int))
x, [String
"UnitDefn"])) (Map UID (UnitDefn, Int) -> [(UID, (UnitDefn, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (UnitDefn, Int) -> [(UID, (UnitDefn, Int))])
-> Map UID (UnitDefn, Int) -> [(UID, (UnitDefn, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (UnitDefn, Int)) ChunkDB (Map UID (UnitDefn, Int))
-> Map UID (UnitDefn, Int)
forall s a. s -> Getting a s a -> a
^. Getting (Map UID (UnitDefn, Int)) ChunkDB (Map UID (UnitDefn, Int))
Lens' ChunkDB (Map UID (UnitDefn, Int))
unitTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (DataDefinition, Int)) -> (UID, [String]))
-> [(UID, (DataDefinition, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (DataDefinition, Int))
x -> ((UID, (DataDefinition, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (DataDefinition, Int))
x, [String
"DataDefinition"])) (Map UID (DataDefinition, Int) -> [(UID, (DataDefinition, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (DataDefinition, Int) -> [(UID, (DataDefinition, Int))])
-> Map UID (DataDefinition, Int) -> [(UID, (DataDefinition, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (DataDefinition, Int))
     ChunkDB
     (Map UID (DataDefinition, Int))
-> Map UID (DataDefinition, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (DataDefinition, Int))
  ChunkDB
  (Map UID (DataDefinition, Int))
Lens' ChunkDB (Map UID (DataDefinition, Int))
dataDefnTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (InstanceModel, Int)) -> (UID, [String]))
-> [(UID, (InstanceModel, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (InstanceModel, Int))
x -> ((UID, (InstanceModel, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (InstanceModel, Int))
x, [String
"InstanceModel"])) (Map UID (InstanceModel, Int) -> [(UID, (InstanceModel, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (InstanceModel, Int) -> [(UID, (InstanceModel, Int))])
-> Map UID (InstanceModel, Int) -> [(UID, (InstanceModel, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (InstanceModel, Int))
     ChunkDB
     (Map UID (InstanceModel, Int))
-> Map UID (InstanceModel, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (InstanceModel, Int))
  ChunkDB
  (Map UID (InstanceModel, Int))
Lens' ChunkDB (Map UID (InstanceModel, Int))
insmodelTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (GenDefn, Int)) -> (UID, [String]))
-> [(UID, (GenDefn, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map
    (\(UID, (GenDefn, Int))
x -> ((UID, (GenDefn, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (GenDefn, Int))
x, [String
"GeneralDefinition"]))
    (Map UID (GenDefn, Int) -> [(UID, (GenDefn, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (GenDefn, Int) -> [(UID, (GenDefn, Int))])
-> Map UID (GenDefn, Int) -> [(UID, (GenDefn, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (GenDefn, Int)) ChunkDB (Map UID (GenDefn, Int))
-> Map UID (GenDefn, Int)
forall s a. s -> Getting a s a -> a
^. Getting (Map UID (GenDefn, Int)) ChunkDB (Map UID (GenDefn, Int))
Lens' ChunkDB (Map UID (GenDefn, Int))
gendefTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (TheoryModel, Int)) -> (UID, [String]))
-> [(UID, (TheoryModel, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (TheoryModel, Int))
x -> ((UID, (TheoryModel, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (TheoryModel, Int))
x, [String
"TheoryModel"])) (Map UID (TheoryModel, Int) -> [(UID, (TheoryModel, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (TheoryModel, Int) -> [(UID, (TheoryModel, Int))])
-> Map UID (TheoryModel, Int) -> [(UID, (TheoryModel, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (TheoryModel, Int)) ChunkDB (Map UID (TheoryModel, Int))
-> Map UID (TheoryModel, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (TheoryModel, Int)) ChunkDB (Map UID (TheoryModel, Int))
Lens' ChunkDB (Map UID (TheoryModel, Int))
theoryModelTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (ConceptInstance, Int)) -> (UID, [String]))
-> [(UID, (ConceptInstance, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map
    (\(UID, (ConceptInstance, Int))
x -> ((UID, (ConceptInstance, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (ConceptInstance, Int))
x, [String
"ConceptInstance"]))
    (Map UID (ConceptInstance, Int) -> [(UID, (ConceptInstance, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (ConceptInstance, Int) -> [(UID, (ConceptInstance, Int))])
-> Map UID (ConceptInstance, Int)
-> [(UID, (ConceptInstance, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (ConceptInstance, Int))
     ChunkDB
     (Map UID (ConceptInstance, Int))
-> Map UID (ConceptInstance, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (ConceptInstance, Int))
  ChunkDB
  (Map UID (ConceptInstance, Int))
Lens' ChunkDB (Map UID (ConceptInstance, Int))
conceptinsTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (Section, Int)) -> (UID, [String]))
-> [(UID, (Section, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (Section, Int))
x -> ((UID, (Section, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (Section, Int))
x, [String
"Section"])) (Map UID (Section, Int) -> [(UID, (Section, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (Section, Int) -> [(UID, (Section, Int))])
-> Map UID (Section, Int) -> [(UID, (Section, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (Section, Int)) ChunkDB (Map UID (Section, Int))
-> Map UID (Section, Int)
forall s a. s -> Getting a s a -> a
^. Getting (Map UID (Section, Int)) ChunkDB (Map UID (Section, Int))
Lens' ChunkDB (Map UID (Section, Int))
sectionTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (LabelledContent, Int)) -> (UID, [String]))
-> [(UID, (LabelledContent, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map
    (\(UID, (LabelledContent, Int))
x -> ((UID, (LabelledContent, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (LabelledContent, Int))
x, [String
"LabelledContent"]))
    (Map UID (LabelledContent, Int) -> [(UID, (LabelledContent, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (LabelledContent, Int) -> [(UID, (LabelledContent, Int))])
-> Map UID (LabelledContent, Int)
-> [(UID, (LabelledContent, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (LabelledContent, Int))
     ChunkDB
     (Map UID (LabelledContent, Int))
-> Map UID (LabelledContent, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (LabelledContent, Int))
  ChunkDB
  (Map UID (LabelledContent, Int))
Lens' ChunkDB (Map UID (LabelledContent, Int))
labelledcontentTable)
  [(UID, [String])] -> [(UID, [String])] -> [(UID, [String])]
forall a. [a] -> [a] -> [a]
++ ((UID, (Reference, Int)) -> (UID, [String]))
-> [(UID, (Reference, Int))] -> [(UID, [String])]
forall a b. (a -> b) -> [a] -> [b]
map (\(UID, (Reference, Int))
x -> ((UID, (Reference, Int)) -> UID
forall a b. (a, b) -> a
fst (UID, (Reference, Int))
x, [String
"Reference"])) (Map UID (Reference, Int) -> [(UID, (Reference, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (Reference, Int) -> [(UID, (Reference, Int))])
-> Map UID (Reference, Int) -> [(UID, (Reference, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (Reference, Int)) ChunkDB (Map UID (Reference, Int))
-> Map UID (Reference, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (Reference, Int)) ChunkDB (Map UID (Reference, Int))
Lens' ChunkDB (Map UID (Reference, Int))
refTable)

-- Currently Unused
-- | Get all 'UID's from a database ('ChunkDB').
mkListAll :: ChunkDB -> [UID]
mkListAll :: ChunkDB -> [UID]
mkListAll ChunkDB
db = [UID] -> [UID]
forall a. Ord a => [a] -> [a]
nubOrd
  ([UID] -> [UID]) -> [UID] -> [UID]
forall a b. (a -> b) -> a -> b
$ [UID] -> [UID]
forall a. Ord a => [a] -> [a]
sort
  ([UID] -> [UID]) -> [UID] -> [UID]
forall a b. (a -> b) -> a -> b
$ ((UID, (QuantityDict, Int)) -> UID)
-> [(UID, (QuantityDict, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (QuantityDict, Int)) -> UID
forall a b. (a, b) -> a
fst (UMap QuantityDict -> [(UID, (QuantityDict, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap QuantityDict -> [(UID, (QuantityDict, Int))])
-> UMap QuantityDict -> [(UID, (QuantityDict, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap QuantityDict
symbolTable ChunkDB
db)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (IdeaDict, Int)) -> UID)
-> [(UID, (IdeaDict, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (IdeaDict, Int)) -> UID
forall a b. (a, b) -> a
fst (UMap IdeaDict -> [(UID, (IdeaDict, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap IdeaDict -> [(UID, (IdeaDict, Int))])
-> UMap IdeaDict -> [(UID, (IdeaDict, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap IdeaDict
termTable ChunkDB
db)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (ConceptChunk, Int)) -> UID)
-> [(UID, (ConceptChunk, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (ConceptChunk, Int)) -> UID
forall a b. (a, b) -> a
fst (UMap ConceptChunk -> [(UID, (ConceptChunk, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (UMap ConceptChunk -> [(UID, (ConceptChunk, Int))])
-> UMap ConceptChunk -> [(UID, (ConceptChunk, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB -> UMap ConceptChunk
defTable ChunkDB
db)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (UnitDefn, Int)) -> UID)
-> [(UID, (UnitDefn, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (UnitDefn, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (UnitDefn, Int) -> [(UID, (UnitDefn, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (UnitDefn, Int) -> [(UID, (UnitDefn, Int))])
-> Map UID (UnitDefn, Int) -> [(UID, (UnitDefn, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (UnitDefn, Int)) ChunkDB (Map UID (UnitDefn, Int))
-> Map UID (UnitDefn, Int)
forall s a. s -> Getting a s a -> a
^. Getting (Map UID (UnitDefn, Int)) ChunkDB (Map UID (UnitDefn, Int))
Lens' ChunkDB (Map UID (UnitDefn, Int))
unitTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, [UID]) -> UID) -> [(UID, [UID])] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, [UID]) -> UID
forall a b. (a, b) -> a
fst (Map UID [UID] -> [(UID, [UID])]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID [UID] -> [(UID, [UID])])
-> Map UID [UID] -> [(UID, [UID])]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting (Map UID [UID]) ChunkDB (Map UID [UID]) -> Map UID [UID]
forall s a. s -> Getting a s a -> a
^. Getting (Map UID [UID]) ChunkDB (Map UID [UID])
Lens' ChunkDB (Map UID [UID])
traceTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, [UID]) -> UID) -> [(UID, [UID])] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, [UID]) -> UID
forall a b. (a, b) -> a
fst (Map UID [UID] -> [(UID, [UID])]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID [UID] -> [(UID, [UID])])
-> Map UID [UID] -> [(UID, [UID])]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting (Map UID [UID]) ChunkDB (Map UID [UID]) -> Map UID [UID]
forall s a. s -> Getting a s a -> a
^. Getting (Map UID [UID]) ChunkDB (Map UID [UID])
Lens' ChunkDB (Map UID [UID])
refbyTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (DataDefinition, Int)) -> UID)
-> [(UID, (DataDefinition, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (DataDefinition, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (DataDefinition, Int) -> [(UID, (DataDefinition, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (DataDefinition, Int) -> [(UID, (DataDefinition, Int))])
-> Map UID (DataDefinition, Int) -> [(UID, (DataDefinition, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (DataDefinition, Int))
     ChunkDB
     (Map UID (DataDefinition, Int))
-> Map UID (DataDefinition, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (DataDefinition, Int))
  ChunkDB
  (Map UID (DataDefinition, Int))
Lens' ChunkDB (Map UID (DataDefinition, Int))
dataDefnTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (InstanceModel, Int)) -> UID)
-> [(UID, (InstanceModel, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (InstanceModel, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (InstanceModel, Int) -> [(UID, (InstanceModel, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (InstanceModel, Int) -> [(UID, (InstanceModel, Int))])
-> Map UID (InstanceModel, Int) -> [(UID, (InstanceModel, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (InstanceModel, Int))
     ChunkDB
     (Map UID (InstanceModel, Int))
-> Map UID (InstanceModel, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (InstanceModel, Int))
  ChunkDB
  (Map UID (InstanceModel, Int))
Lens' ChunkDB (Map UID (InstanceModel, Int))
insmodelTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (GenDefn, Int)) -> UID) -> [(UID, (GenDefn, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (GenDefn, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (GenDefn, Int) -> [(UID, (GenDefn, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (GenDefn, Int) -> [(UID, (GenDefn, Int))])
-> Map UID (GenDefn, Int) -> [(UID, (GenDefn, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (GenDefn, Int)) ChunkDB (Map UID (GenDefn, Int))
-> Map UID (GenDefn, Int)
forall s a. s -> Getting a s a -> a
^. Getting (Map UID (GenDefn, Int)) ChunkDB (Map UID (GenDefn, Int))
Lens' ChunkDB (Map UID (GenDefn, Int))
gendefTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (TheoryModel, Int)) -> UID)
-> [(UID, (TheoryModel, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (TheoryModel, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (TheoryModel, Int) -> [(UID, (TheoryModel, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (TheoryModel, Int) -> [(UID, (TheoryModel, Int))])
-> Map UID (TheoryModel, Int) -> [(UID, (TheoryModel, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (TheoryModel, Int)) ChunkDB (Map UID (TheoryModel, Int))
-> Map UID (TheoryModel, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (TheoryModel, Int)) ChunkDB (Map UID (TheoryModel, Int))
Lens' ChunkDB (Map UID (TheoryModel, Int))
theoryModelTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (ConceptInstance, Int)) -> UID)
-> [(UID, (ConceptInstance, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (ConceptInstance, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (ConceptInstance, Int) -> [(UID, (ConceptInstance, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (ConceptInstance, Int) -> [(UID, (ConceptInstance, Int))])
-> Map UID (ConceptInstance, Int)
-> [(UID, (ConceptInstance, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (ConceptInstance, Int))
     ChunkDB
     (Map UID (ConceptInstance, Int))
-> Map UID (ConceptInstance, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (ConceptInstance, Int))
  ChunkDB
  (Map UID (ConceptInstance, Int))
Lens' ChunkDB (Map UID (ConceptInstance, Int))
conceptinsTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (Section, Int)) -> UID) -> [(UID, (Section, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (Section, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (Section, Int) -> [(UID, (Section, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (Section, Int) -> [(UID, (Section, Int))])
-> Map UID (Section, Int) -> [(UID, (Section, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (Section, Int)) ChunkDB (Map UID (Section, Int))
-> Map UID (Section, Int)
forall s a. s -> Getting a s a -> a
^. Getting (Map UID (Section, Int)) ChunkDB (Map UID (Section, Int))
Lens' ChunkDB (Map UID (Section, Int))
sectionTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (LabelledContent, Int)) -> UID)
-> [(UID, (LabelledContent, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (LabelledContent, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (LabelledContent, Int) -> [(UID, (LabelledContent, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (LabelledContent, Int) -> [(UID, (LabelledContent, Int))])
-> Map UID (LabelledContent, Int)
-> [(UID, (LabelledContent, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (LabelledContent, Int))
     ChunkDB
     (Map UID (LabelledContent, Int))
-> Map UID (LabelledContent, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (LabelledContent, Int))
  ChunkDB
  (Map UID (LabelledContent, Int))
Lens' ChunkDB (Map UID (LabelledContent, Int))
labelledcontentTable)
  [UID] -> [UID] -> [UID]
forall a. [a] -> [a] -> [a]
++ ((UID, (Reference, Int)) -> UID)
-> [(UID, (Reference, Int))] -> [UID]
forall a b. (a -> b) -> [a] -> [b]
map (UID, (Reference, Int)) -> UID
forall a b. (a, b) -> a
fst (Map UID (Reference, Int) -> [(UID, (Reference, Int))]
forall k a. Map k a -> [(k, a)]
Map.assocs (Map UID (Reference, Int) -> [(UID, (Reference, Int))])
-> Map UID (Reference, Int) -> [(UID, (Reference, Int))]
forall a b. (a -> b) -> a -> b
$ ChunkDB
db ChunkDB
-> Getting
     (Map UID (Reference, Int)) ChunkDB (Map UID (Reference, Int))
-> Map UID (Reference, Int)
forall s a. s -> Getting a s a -> a
^. Getting
  (Map UID (Reference, Int)) ChunkDB (Map UID (Reference, Int))
Lens' ChunkDB (Map UID (Reference, Int))
refTable)