From b282af35ad4b0bb8d90e517f4b9ff03c22234090 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Wed, 7 Sep 2022 15:07:04 +0200 Subject: Copy-edit specification --- src/exe/Main.lhs | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'src/exe/Main.lhs') diff --git a/src/exe/Main.lhs b/src/exe/Main.lhs index 2f67ffd..dc360fd 100644 --- a/src/exe/Main.lhs +++ b/src/exe/Main.lhs @@ -12,27 +12,20 @@ User interface > import Codec.Pesto.Lint (lint, extractMetadata, Metadata(..), LintResult (LintResult)) > import Codec.Pesto.Serialize (serialize) -The user-interface has different modes of operation. All of them read a single -recipe from the standard input. +The user-interface reads a single recipe from the standard input. > main = do > (op:_) <- getArgs > s <- getContents -> either malformedRecipe (run op) (parse s) +> either malformedRecipe (run op) (parse s) + +It has three modes of operation, described in the next sections. > run "dot" = runDot > run "metadata" = runMeta > run "ingredients" = runIngredients > run _ = const (putStrLn "unknown operation") -> malformedRecipe = print - -> streamToGraph stream = (nodes, edges) -> where -> doc = (head . extract . snd . unzip) stream -> nodes = zip [firstNodeId..] doc -> edges = toGraph nodes ++ resolveReferences nodes - dot ^^^ @@ -41,7 +34,7 @@ can represent recipes as well. Example: .. code:: bash - cabal run --verbose=0 pesto dot < spaghetti.pesto | dot -Tpng > spaghetti.png + cabal run --verbose=0 pesto dot < spaghetti.pesto | dot -Tpng > spaghetti.png > runDot stream = putStrLn $ toDot dotNodes dotEdges > where @@ -50,10 +43,10 @@ can represent recipes as well. Example: > (lintNodes, lintEdges) = unzip $ map (uncurry lintToNodesEdges) > $ zip [maxId..] (lint nodes edges) > dotNodes = concat [ -> [("node", [("fontname", "Roboto Semi-Light")])] +> [("node", [("fontname", "Roboto Semi-Light")])] > , map (\(a, label) -> (show a, [("label", serialize label)])) nodes > , lintNodes -> ] +> ] > dotEdges = concat [ > map (both show) edges > , concat lintEdges @@ -72,7 +65,7 @@ can represent recipes as well. Example: > <> "}" > where > edgeToDot (a, b) = a <> " -> " <> b <> ";" -> nodeToDot (a, b) = a <> " [" <> mconcat (mapToDot b) <> "];" +> nodeToDot (a, b) = a <> " [" <> mconcat (mapToDot b) <> "];" > mapToDot = map kvToDot > kvToDot (k, v) = k <> "=\"" <> quoteString v <> "\"" @@ -104,3 +97,14 @@ alternatives into account yet. > csvQty (Quantity a b c) = intercalate "," [serialize a, b, c] +Appendix +^^^^^^^^ + +> malformedRecipe = print + +> streamToGraph stream = (nodes, edges) +> where +> doc = (head . extract . snd . unzip) stream +> nodes = zip [firstNodeId..] doc +> edges = toGraph nodes ++ resolveReferences nodes + -- cgit v1.2.3