summaryrefslogtreecommitdiff
path: root/src/Main.lhs
blob: 5b37b8e431c0d7829b5569bcd2aaf008e1aaf911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
User interface
++++++++++++++

.. class:: nodoc

> module Main (main) where
> import Codec.Pesto.Parse (parse, Recipe(..))
> import Codec.Pesto.Graph (toGraph, firstNodeId, resolveReferences)
> import Codec.Pesto.Lint (lint)
> import Codec.Pesto.Dot (toDot)

The pesto to dot converter can be run with ``cabal run pesto``. It expects a
pesto recipe on the standard input and prints a dot graph to stdout that can be
converted to an image by piping it through ``dot -Tpng``. Example:

.. code:: bash

	cabal run --verbose=0 pesto < spaghetti.pesto | dot -Tpng > spaghetti.png

.. class:: todo

add linting information to graph

> main = do
> 	s <- getContents
>	(flip . either) malformedRecipe (parse s) $ \doc -> do
> 		let
> 			nodes = (zip [firstNodeId..] . snd . unzip . operations) doc
> 			edges = toGraph nodes ++ resolveReferences nodes
> 		--print $ lint nodes edges
> 		putStrLn $ toDot nodes edges

> malformedRecipe = print