hmt-diagrams-0.14: Haskell Music Theory Diagrams

Safe HaskellSafe-Inferred




Functions to make path diagrams such as those in Fig. VIII-11 on I.Xenakis Formalized Music.



parts :: [a] -> [([a], a, [a])]Source

Set of all (pre,element,post) triples of a sequence.

 parts "abc" == [("",'a',"bc"),("a",'b',"c"),("ab",'c',"")]

parts' :: [a] -> [(a, [a])]Source

All (element,remainder) pairs for a sequence.

 parts' "abc" == [('a',"bc"),('b',"ac"),('c',"ab")]

gather :: Ord a => [(a, i)] -> [(a, [i])]Source

Gather elements with equal keys.

 gather (zip "abcba" [0..]) == [('a',[0,4]),('b',[1,3]),('c',[2])]


ln_on :: Ln R -> Ln R -> BoolSource

Does either endpoint of the lhs Ln lie on the rhs Ln.

 ln_on (ln' (1/2,1/2) (1/2,1)) (ln' (0,0) (1,1)) == True
 ln_on (ln' (1/2,0) (1/2,1)) (ln' (0,0) (1,1)) == False

overlap :: Ln R -> Ln R -> BoolSource

Do Lns overlap in the particular sense of being ln_parallel and at least one endpoint of one line lying on the other.

includes :: Ln R -> Ln R -> BoolSource

Do both points of the rhs Ln lie on the lhs Ln.

pt_fn :: ((a, a) -> b) -> Pt a -> bSource

Apply f to x and y duple of Pt.

ln_fn :: (Num a, Eq a) => ((Pt a, Pt a) -> b) -> Ln a -> bSource

Apply f to start and end Pt duple of Ln.

ln_pt_fn :: (Num a, Eq a, Num b, Eq b) => (Pt a -> Pt b) -> Ln a -> Ln bSource

Apply f to start and end Pts of Ln and construct Ln.

to_unit :: R -> [Ln R] -> [Ln R]Source

Scale set of Ln to lie in area given by (0,n).


data Orientation a Source

Enumeration of Vertical, Horizontal and Diagonal.


Diagonal a 


Eq a => Eq (Orientation a) 
Show a => Show (Orientation a) 

orientation :: (Fractional a, Eq a) => Ln a -> Orientation aSource

Calculate Orientation of Ln.

 orientation (ln' (0,0) (0,1)) == Vertical
 orientation (ln' (0,0) (1,0)) == Horizontal
 orientation (ln' (0,0) (1,1)) == Diagonal 1

Shift Map

type Shift_Map a = [(Pt a, [Orientation a])]Source

A table Pt and Orientation set pairs.

mk_shift_map :: [Ln R] -> Shift_Map RSource

Construct a Shift_Map from a set of Lns.

Shift table

type Shift_Table a = [(Pt a, Pt a)]Source

A table of Pt pairs.

Collision table

type Collision_Table = [(Ln R, Bool)]Source

Table of Lns indicating collisions.

Path diagram

type Path_Diagram = [(Int, Int)]Source

A diagram given as a set of Int pairs.

path_diagram_ln :: Path_Diagram -> [Ln R]Source

Construct set of Ln from Path_Diagram.