graphviz-2999.17.0.2: Bindings to Graphviz for graph visualisation.

Copyright(c) Ivan Lazar Miljenovic
License3-Clause BSD-style
MaintainerIvan.Miljenovic@gmail.com
Safe HaskellNone
LanguageHaskell2010

Data.GraphViz.Commands.IO

Contents

Description

Various utility functions to help with custom I/O of Dot code.

Synopsis

Encoding

By default, Dot code should be in UTF-8. However, by usage of the charset attribute, users are able to specify that the ISO-8859-1 (aka Latin1) encoding should be used instead: http://www.graphviz.org/doc/info/attrs.html#d:charset

To simplify matters, graphviz does not work with ISO-8859-1. If you wish to deal with existing Dot code that uses this encoding, you will need to manually read that file in to a Text value.

If a non-UTF-8 encoding is used, then a GraphvizException will be thrown.

toUTF8 :: ByteString -> Text Source

Explicitly convert a (lazy) ByteString to a Text value using UTF-8 encoding, throwing a GraphvizException if there is a decoding error.

Operations on files

writeDotFile :: PrintDotRepr dg n => FilePath -> dg n -> IO () Source

Write the specified DotRepr to file.

readDotFile :: ParseDotRepr dg n => FilePath -> IO (dg n) Source

Read in and parse a DotRepr value from a file.

Operations on handles

hPutDot :: PrintDotRepr dg n => Handle -> dg n -> IO () Source

Output the DotRepr to the specified Handle.

hPutCompactDot :: PrintDotRepr dg n => Handle -> dg n -> IO () Source

Output the DotRepr to the spcified Handle in a more compact, machine-oriented form.

hGetDot :: ParseDotRepr dg n => Handle -> IO (dg n) Source

Read in and parse a DotRepr value from the specified Handle.

hGetStrict :: Handle -> IO Text Source

Strictly read in a Text value using an appropriate encoding.

Special cases for standard input and output

putDot :: PrintDotRepr dg n => dg n -> IO () Source

Print the specified DotRepr to stdout.

readDot :: ParseDotRepr dg n => IO (dg n) Source

Read in and parse a DotRepr value from stdin.

Running external commands

runCommand Source

Arguments

:: PrintDotRepr dg n 
=> String

Command to run

-> [String]

Command-line arguments

-> (Handle -> IO a)

Obtaining the output; should be strict.

-> dg n 
-> IO a 

Run an external command on the specified DotRepr. Remember to use hSetBinaryMode on the Handle for the output function if necessary.

If the command was unsuccessful, then a GraphvizException is thrown.

For performance reasons, a temporary file is used to store the generated Dot code. As such, this is only suitable for local commands.