summaryrefslogtreecommitdiff
path: root/src/Main.lhs
blob: 00123d58c7f85155cf525f36370d56870ac2e2fb (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
35
User interface
++++++++++++++

.. class:: nodoc

> module Main (main) where
> import Codec.Pesto.Parse (parse)
> import Codec.Pesto.Graph (extract, 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) $ \stream -> do
> 		let
> 			doc = (head . extract . snd . unzip) stream
> 			nodes = zip [firstNodeId..] doc
> 			edges = toGraph nodes ++ resolveReferences nodes
> 		--print $ lint nodes edges
> 		putStrLn $ toDot nodes edges

> malformedRecipe = print