diff options
| author | Simon-Kor <52245124+Simon-Kor@users.noreply.github.com> | 2024-09-23 03:14:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-23 03:14:06 +0200 |
| commit | 8fd49ae84e8cc4524c19b20fa0aabb4e77a46cd5 (patch) | |
| tree | 9848da3e57979a5a7e14ec99ee103cfa079e6fcb /source/TheoryGraph.hs | |
| parent | 18c79bcb98fb376f15b2b3e00972530df61b26a9 (diff) | |
| parent | f6b22fd533bd61e9dbcb6374295df321de99b1f2 (diff) | |
Abgabe
Submission of Formalisation
Diffstat (limited to 'source/TheoryGraph.hs')
| -rw-r--r-- | source/TheoryGraph.hs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/source/TheoryGraph.hs b/source/TheoryGraph.hs index c4887ea..e49bc1f 100644 --- a/source/TheoryGraph.hs +++ b/source/TheoryGraph.hs @@ -67,12 +67,12 @@ member :: FilePath -> TheoryGraph -> Bool member n (TheoryGraph g) = Map.member n g --- | Add a node to the TheoryGraph. This is a noop if the node is already present in the graph. +-- | Add a node to the TheoryGraph. addNode :: FilePath -> TheoryGraph -> TheoryGraph addNode a (TheoryGraph g) = TheoryGraph (Map.insertWith Set.union a Set.empty g) --- | Add an edge to the TheoryGraph. This is a noop if the edge is already present in the graph. +-- | Add an edge to the TheoryGraph. This is a loop if the edge is already present in the graph. addPrecedes :: Precedes FilePath -> TheoryGraph -> TheoryGraph addPrecedes e@(Precedes _ a') (TheoryGraph g) = addNode a' (TheoryGraph (insertTail e g)) where @@ -85,7 +85,9 @@ addPrecedes e@(Precedes _ a') (TheoryGraph g) = addNode a' (TheoryGraph (insertT singleton :: FilePath -> TheoryGraph singleton a = TheoryGraph (Map.singleton a Set.empty) - +-- | Construct a graph, from a list of nodes and edges. +-- It takes all nodes a and add the pair (a, emptyset) to the Theorygraph, +-- afterwards it add all edges between the nodes. makeTheoryGraph :: [Precedes FilePath] -> [FilePath] -> TheoryGraph makeTheoryGraph es as = List.foldl' (flip addPrecedes) (TheoryGraph trivial) es where @@ -94,6 +96,8 @@ makeTheoryGraph es as = List.foldl' (flip addPrecedes) (TheoryGraph trivial) es {-# INLINE makeTheoryGraph #-} +-- | Construct a graph, from a list @x:xs@, +-- where @x@ is a pair of theorys @(a,b)@ with @a@ gets imported in @b@. fromList :: [Precedes FilePath] -> TheoryGraph fromList es = TheoryGraph (Map.fromListWith Set.union es') where |
