hmt-0.20: Haskell Music Theory
Safe HaskellSafe-Inferred
LanguageHaskell2010

Music.Theory.Graph.Dot

Description

Graph (dot) functions.

Synopsis

Util

s_classify :: (t -> Bool) -> (t -> Bool) -> ([t] -> Bool) -> [t] -> Bool Source #

Classify s using a first element predicate, a remainder predicate and a unit predicate.

is_symbol :: String -> Bool Source #

Symbol rule.

map is_symbol ["sym","Sym2","3sym","1",""] == [True,True,False,False,False]

is_number :: String -> Bool Source #

Number rule.

map is_number ["123","123.45",".25","1.","1.2.3",""] == [True,True,False,True,False,False]

maybe_quote :: String -> String Source #

Quote s if is_symbol or is_number.

map maybe_quote ["abc","a b c","12","12.3"] == ["abc","\"a b c\"","12","12.3"]

Attr/Key

dot_attr_seq_pp :: [Dot_Attr] -> String Source #

Format sequence of Dot_Attr.

dot_attr_seq_pp [("layout","neato"),("epsilon","0.0001")]

dot_attr_ext :: [Dot_Attr] -> [Dot_Attr] -> [Dot_Attr] Source #

Merge attributes, left-biased.

type Dot_Type = String Source #

graph|node|edge

type Dot_Attr_Set = (Dot_Type, [Dot_Attr]) Source #

(type,[attr])

dot_attr_set_pp :: Dot_Attr_Set -> String Source #

Format Dot_Attr_Set.

a = ("graph",[("layout","neato"),("epsilon","0.0001")])
dot_attr_set_pp a == "graph [layout=neato,epsilon=0.0001]"

type Dot_Meta_Key = String Source #

type:attr (type = graph|node|edge)

dot_key_sep :: Dot_Meta_Key -> (Dot_Type, Dot_Key) Source #

Keys are given as "type:attr".

dot_key_sep "graph:layout" == ("graph","layout")

dot_attr_collate :: [Dot_Meta_Attr] -> [Dot_Attr_Set] Source #

Collate Dot_Key attribute set to Dot_Attr_Set.

dot_attr_def :: (String, String, Double, String) -> [Dot_Meta_Attr] Source #

Default values for default meta-keys.

k = dot_attr_def ("neato","century schoolbook",10,"plaintext")
map dot_attr_set_pp (dot_attr_collate k)

Graph

type Graph_Pp v e = ((Int, v) -> [Dot_Attr], ((Int, Int), e) -> [Dot_Attr]) Source #

Graph pretty-printer, (v -> [attr],e -> [attr])

gr_pp_label_m :: Maybe (v -> Dot_Value) -> Maybe (e -> Dot_Value) -> Graph_Pp v e Source #

Make Graph_Pp value given label functions for vertices and edges.

gr_pp_label :: (v -> Dot_Value) -> (e -> Dot_Value) -> Graph_Pp v e Source #

Label V & E.

gr_pp_label_v :: (v -> Dot_Value) -> Graph_Pp v e Source #

Label V only.

br_csl_pp :: Show t => [t] -> String Source #

br = brace, csl = comma separated list

data Graph_Type Source #

Graph type, directed or un-directed.

node_pos_attr :: (Show n, Real n) => (n, n) -> Dot_Attr Source #

Generate node position attribute given (x,y) coordinate.

edge_pos_attr :: Real t => [(t, t)] -> Dot_Attr Source #

Edge POS attributes are sets of cubic bezier control points.

edge_pos_attr_1 :: Real t => ((t, t), (t, t), (t, t), (t, t)) -> Dot_Attr Source #

Variant that accepts single cubic bezier data set.

fgl_to_dot :: Graph gr => Graph_Type -> [Dot_Meta_Attr] -> Graph_Pp v e -> gr v e -> [String] Source #

fgl_to_udot :: Graph gr => [Dot_Meta_Attr] -> Graph_Pp v e -> gr v e -> [String] Source #

Dot-Process

dot_to_ext :: [String] -> FilePath -> FilePath -> IO () Source #

Run dot to generate a file type based on the output file extension (ie. .svg, .png, .jpeg, .gif) -n must be given to not run the layout algorithm and to use position data in the dot file.

dot_to_svg :: [String] -> FilePath -> IO () Source #

dot_to_ext generating .svg filename by replacing .dot extension with .svg