diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2022-08-29 15:58:16 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2022-08-29 15:58:16 +0200 |
commit | ca737457a4df4fbca25fe1c94c358a5b3b8da173 (patch) | |
tree | 037747046b8ba79f7882dfb4a5b0146ea81dac91 /src/lib/Codec | |
parent | c03c0ff4437ba4c9169b6f240f062cd3df40a023 (diff) | |
download | pesto-ca737457a4df4fbca25fe1c94c358a5b3b8da173.tar.gz pesto-ca737457a4df4fbca25fe1c94c358a5b3b8da173.tar.bz2 pesto-ca737457a4df4fbca25fe1c94c358a5b3b8da173.zip |
graph: Use node id when querying incoming/outcoming nodes/edges
Diffstat (limited to 'src/lib/Codec')
-rw-r--r-- | src/lib/Codec/Pesto/Graph.lhs | 8 | ||||
-rw-r--r-- | src/lib/Codec/Pesto/Lint.lhs | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/src/lib/Codec/Pesto/Graph.lhs b/src/lib/Codec/Pesto/Graph.lhs index 27dd967..a238012 100644 --- a/src/lib/Codec/Pesto/Graph.lhs +++ b/src/lib/Codec/Pesto/Graph.lhs @@ -266,11 +266,11 @@ Find graph’s root node(s), that is a node without outgoing edges: Get all nodes with edges pointing towards nodeid -> incomingEdges edges (nodeid, _) = filter ((==) nodeid . snd) edges -> incomingNodes nodes edges n = map ((!!) nodes . fst) $ incomingEdges edges n +> incomingEdges edges nodeid = filter ((==) nodeid . snd) edges +> incomingNodes nodes edges nodeid = map ((!!) nodes . fst) $ incomingEdges edges nodeid -> outgoingEdges edges (nodeid, _) = filter ((==) nodeid . fst) edges -> outgoingNodes nodes edges n = map ((!!) nodes . snd) $ outgoingEdges edges n +> outgoingEdges edges nodeid = filter ((==) nodeid . fst) edges +> outgoingNodes nodes edges nodeid = map ((!!) nodes . snd) $ outgoingEdges edges nodeid > test = ["graph" ~: testGraph, "ref" ~: testRef, "extract" ~: testExtract] diff --git a/src/lib/Codec/Pesto/Lint.lhs b/src/lib/Codec/Pesto/Lint.lhs index 480d161..affea98 100644 --- a/src/lib/Codec/Pesto/Lint.lhs +++ b/src/lib/Codec/Pesto/Lint.lhs @@ -71,10 +71,10 @@ The graph’s root node must be a result. It contains yield (amount and unit) an title (object) of the recipe. > extractMetadata nodes edges = case walkRoot nodes edges of -> [n@(i, Result q@(Quantity _ _ title))] -> +> [(i, Result q@(Quantity _ _ title))] -> > Just $ (i, ("title", MetaStr title)) > :(i, ("yield", MetaQty q)) -> :foldl f [] (incomingNodes nodes edges n) +> :foldl f [] (incomingNodes nodes edges i) > _ -> Nothing > where @@ -196,7 +196,7 @@ minutes). More time annotations improve the software’s scheduling capabilities > timeAnnotatesAction nodes edges = foldl f [] nodes > where -> f xs n@(nodeid, Tool q) | isTime q && (not . allActions) (outgoingEdges edges n) = LintResult TimeAnnotatesAction [nodeid]:xs +> f xs (nodeid, Tool q) | isTime q && (not . allActions) (outgoingEdges edges nodeid) = LintResult TimeAnnotatesAction [nodeid]:xs > f xs _ = xs > toNodelist = (!!) nodes . snd > allActions = all (isAction . snd . toNodelist) @@ -273,7 +273,7 @@ all results and alternatives are referenced at some point. > referencesResolved nodes edges = foldl f [] nodes > where -> f xs n@(nodeid, Reference _) | null (incomingEdges edges n) = +> f xs (nodeid, Reference _) | null (incomingEdges edges nodeid) = > LintResult UndefinedReference [nodeid]:xs > f xs _ = xs @@ -311,7 +311,7 @@ only occur at the beginning of a recipe. > resultNonempty nodes edges = foldl f [] nodes > where -> f xs n@(nodeid, Result _) | null (incomingEdges edges n) = +> f xs (nodeid, Result _) | null (incomingEdges edges nodeid) = > LintResult TooFewChildren [nodeid]:xs > f xs _ = xs @@ -326,7 +326,7 @@ make the alternative pointless. > twoAlternatives nodes edges = foldl f [] nodes > where -> f xs n@(nodeid, Alternative _) | length (incomingEdges edges n) < 2 = +> f xs (nodeid, Alternative _) | length (incomingEdges edges nodeid) < 2 = > LintResult TooFewChildren [nodeid]:xs > f xs _ = xs |