Safe Haskell | Safe-Inferred |
---|
Operations on Skeleton
s.
A skeleton is a tree, but it's stored as a Data.Graph and converted to a tree when needed. This seems weird, but at the time it seemed overly awkward to add and remove edges to a tree, and to detect cycles, while graphs have those operations built in. In retrospect, dealing with Data.Graph was probably more of a pain, so maybe someday if I have a lot of extra time and feel like some aggravation I'll see about redoing Skeleton as a Tree. I could also maybe clean up Ui.TrackTree.
Synopsis
- data Skeleton
- type Edge = (TrackNum, TrackNum)
- empty :: Skeleton
- make :: [Edge] -> Skeleton
- draw :: Skeleton -> String
- has_edge :: Skeleton -> Edge -> Bool
- add_edges :: [Edge] -> Skeleton -> Maybe Skeleton
- remove_edges :: [Edge] -> Skeleton -> Skeleton
- lonely_vertex :: Skeleton -> TrackNum -> Bool
- flatten :: Skeleton -> [Edge]
- to_forest :: TrackNum -> Skeleton -> [Tree.Tree TrackNum]
- parents :: Skeleton -> TrackNum -> [TrackNum]
- children :: Skeleton -> TrackNum -> [TrackNum]
- insert :: TrackNum -> Skeleton -> Skeleton
- remove :: TrackNum -> Skeleton -> Skeleton
- toggle_edge :: Edge -> Skeleton -> Maybe Skeleton
- splice_above :: TrackNum -> TrackNum -> Skeleton -> Maybe Skeleton
- splice_below :: TrackNum -> TrackNum -> Skeleton -> Maybe Skeleton
- move :: TrackNum -> TrackNum -> Skeleton -> Skeleton
Documentation
The skeleton describes a hierarchical relationship between tracks. It's used at the UI level only to display the hierarchy visually, but the deriver level will presumably use it for derivation. A given track may appear multiple times or not at all.
:: TrackNum | Total number of tracks. This is needed because the underlying graph may be smaller than the number of tracks. I don't want to allow a skeleton that doesn't have certain tracks (and hence makes them invisible) so any missing tracks are appended. |
-> Skeleton | |
-> [Tree.Tree TrackNum] | Each list of Nodes is sorted so the tree appears in the same order as the tracks. This is essential for calls that want to deal with tracks left-to-right. |
insert :: TrackNum -> Skeleton -> Skeleton Source #
Increment all vertices at and above, insert new empty vertex.