summaryrefslogtreecommitdiff
path: root/src/exe
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2023-01-19 14:56:41 +0100
committerLars-Dominik Braun <lars@6xq.net>2023-01-19 14:56:41 +0100
commitcc2aaa6e46dfac12dfad39414925d5a535a91d19 (patch)
treea257c2cecf7344263bc9775828fc47689423da2d /src/exe
parent623f8efba15e167ebae89618cb5362c3f9486ec0 (diff)
downloadpesto-cc2aaa6e46dfac12dfad39414925d5a535a91d19.tar.gz
pesto-cc2aaa6e46dfac12dfad39414925d5a535a91d19.tar.bz2
pesto-cc2aaa6e46dfac12dfad39414925d5a535a91d19.zip
graph: Add ingredient mergingHEADmaster
Diffstat (limited to 'src/exe')
-rw-r--r--src/exe/Main.lhs8
1 files changed, 4 insertions, 4 deletions
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