From cc2aaa6e46dfac12dfad39414925d5a535a91d19 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Thu, 19 Jan 2023 14:56:41 +0100 Subject: graph: Add ingredient merging --- src/exe/Main.lhs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/exe/Main.lhs') diff --git a/src/exe/Main.lhs b/src/exe/Main.lhs index dc360fd..ae663ad 100644 --- a/src/exe/Main.lhs +++ b/src/exe/Main.lhs @@ -8,7 +8,7 @@ User interface > import Data.List (intercalate) > > import Codec.Pesto.Parse (parse, Instruction (Ingredient), Quantity (..)) -> import Codec.Pesto.Graph (extract, toGraph, firstNodeId, resolveReferences) +> import Codec.Pesto.Graph (extract, toGraph, firstNodeId, resolveReferences, extractIngredients, mergeQuantity) > import Codec.Pesto.Lint (lint, extractMetadata, Metadata(..), LintResult (LintResult)) > import Codec.Pesto.Serialize (serialize) @@ -87,10 +87,10 @@ ingredients Extract ingredients and print them in CSV format. This does not take alternatives into account yet. -> runIngredients stream = mapM_ (putStrLn . csvQty) $ reverse $ foldl getIngredient [] stream +> runIngredients stream = mapM_ (putStrLn . csvQty) $ ingredients > where -> getIngredient xs (_, Ingredient q) = q:xs -> getIngredient xs _ = xs +> (nodes, _) = streamToGraph stream +> ingredients = mergeQuantity $ extractIngredients nodes > printMeta (_, (key, MetaStr value)) = putStrLn $ key ++ "=" ++ value > printMeta (_, (key, MetaQty q)) = putStrLn $ key ++ "=" ++ csvQty q -- cgit v1.2.3