Karya, built on Sun Nov 26 01:04:37 PST 2017 (patch 0a920b2bde70c0cbac8ee09d158064798b61bbe5)

Safe HaskellNone

Derive.Solkattu.Realize

Contents

Description

Realize abstract solkattu S.Notes to concrete instrument-dependent Notes.

Synopsis

Documentation

type SNote stroke = S.Note () (Note stroke) Source #

The group is () because I don't need groups in the stroke map keys.

data Note stroke Source #

The Solkattu.Sollus have been reduced to concrete strokes.

Instances

Functor Note # 

Methods

fmap :: (a -> b) -> Note a -> Note b #

(<$) :: a -> Note b -> Note a #

Eq stroke => Eq (Note stroke) # 

Methods

(==) :: Note stroke -> Note stroke -> Bool #

(/=) :: Note stroke -> Note stroke -> Bool #

Show stroke => Show (Note stroke) # 

Methods

showsPrec :: Int -> Note stroke -> ShowS #

show :: Note stroke -> String #

showList :: [Note stroke] -> ShowS #

DeepSeq.NFData (Note stroke) # 

Methods

rnf :: Note stroke -> () #

Pretty.Pretty stroke => Pretty.Pretty (Note stroke) # 

Methods

pretty :: Note stroke -> Text Source #

format :: Note stroke -> Doc Source #

formatList :: [Note stroke] -> Doc Source #

S.HasMatras (Note stroke) # 

Methods

matras_of :: Note stroke -> S.Matra Source #

has_duration :: Note stroke -> Bool Source #

Rest (SNote sollu) # 

Methods

__ :: SNote sollu Source #

data Stroke stroke Source #

Constructors

Stroke 

Fields

Instances

Functor Stroke # 

Methods

fmap :: (a -> b) -> Stroke a -> Stroke b #

(<$) :: a -> Stroke b -> Stroke a #

Eq stroke => Eq (Stroke stroke) # 

Methods

(==) :: Stroke stroke -> Stroke stroke -> Bool #

(/=) :: Stroke stroke -> Stroke stroke -> Bool #

Ord stroke => Ord (Stroke stroke) # 

Methods

compare :: Stroke stroke -> Stroke stroke -> Ordering #

(<) :: Stroke stroke -> Stroke stroke -> Bool #

(<=) :: Stroke stroke -> Stroke stroke -> Bool #

(>) :: Stroke stroke -> Stroke stroke -> Bool #

(>=) :: Stroke stroke -> Stroke stroke -> Bool #

max :: Stroke stroke -> Stroke stroke -> Stroke stroke #

min :: Stroke stroke -> Stroke stroke -> Stroke stroke #

Show stroke => Show (Stroke stroke) # 

Methods

showsPrec :: Int -> Stroke stroke -> ShowS #

show :: Stroke stroke -> String #

showList :: [Stroke stroke] -> ShowS #

Pretty.Pretty stroke => Pretty.Pretty (Stroke stroke) # 

Methods

pretty :: Stroke stroke -> Text Source #

format :: Stroke stroke -> Doc Source #

formatList :: [Stroke stroke] -> Doc Source #

Expr.ToExpr (Stroke Stroke) # 
Expr.ToExpr (Stroke Stroke) # 
Expr.ToExpr (Stroke Stroke) # 
Expr.ToExpr (Stroke Stroke) # 

stroke :: stroke -> Stroke stroke Source #

rest :: SNote stroke Source #

newtype Patterns stroke Source #

This maps a Pattern of a certain duration to a realization. The S.Matras should the same duration as the the list in the default tempo. This is enforced in the constructor patterns.

Constructors

Patterns (Map Solkattu.Pattern [SNote stroke]) 

Instances

Eq stroke => Eq (Patterns stroke) # 

Methods

(==) :: Patterns stroke -> Patterns stroke -> Bool #

(/=) :: Patterns stroke -> Patterns stroke -> Bool #

Show stroke => Show (Patterns stroke) # 

Methods

showsPrec :: Int -> Patterns stroke -> ShowS #

show :: Patterns stroke -> String #

showList :: [Patterns stroke] -> ShowS #

Monoid (Patterns stroke) # 

Methods

mempty :: Patterns stroke #

mappend :: Patterns stroke -> Patterns stroke -> Patterns stroke #

mconcat :: [Patterns stroke] -> Patterns stroke #

Pretty.Pretty stroke => Pretty.Pretty (Patterns stroke) # 

Methods

pretty :: Patterns stroke -> Text Source #

format :: Patterns stroke -> Doc Source #

formatList :: [Patterns stroke] -> Doc Source #

patterns :: [(Solkattu.Pattern, [SNote stroke])] -> Either Error (Patterns stroke) Source #

Make a Patterns while checking that the durations match.

map_patterns :: ([SNote stroke] -> [SNote stroke]) -> Patterns stroke -> Patterns stroke Source #

StrokeMap

newtype StrokeMap stroke Source #

Sollus and Strokes should be the same length. This is enforced in the constructor stroke_map. Nothing is a rest, which applies to longer sequences like dinga.

Instances

Eq stroke => Eq (StrokeMap stroke) # 

Methods

(==) :: StrokeMap stroke -> StrokeMap stroke -> Bool #

(/=) :: StrokeMap stroke -> StrokeMap stroke -> Bool #

Show stroke => Show (StrokeMap stroke) # 

Methods

showsPrec :: Int -> StrokeMap stroke -> ShowS #

show :: StrokeMap stroke -> String #

showList :: [StrokeMap stroke] -> ShowS #

Monoid (StrokeMap stroke) # 

Methods

mempty :: StrokeMap stroke #

mappend :: StrokeMap stroke -> StrokeMap stroke -> StrokeMap stroke #

mconcat :: [StrokeMap stroke] -> StrokeMap stroke #

Pretty.Pretty stroke => Pretty.Pretty (StrokeMap stroke) # 

Methods

pretty :: StrokeMap stroke -> Text Source #

format :: StrokeMap stroke -> Doc Source #

formatList :: [StrokeMap stroke] -> Doc Source #

simple_stroke_map :: [([Solkattu.Sollu], [Maybe.Maybe stroke])] -> StrokeMap stroke Source #

Directly construct a StrokeMap from strokes.

Instrument

data Instrument stroke Source #

Sollu to instrument stroke mapping.

Constructors

Instrument 

Fields

Instances

Eq stroke => Eq (Instrument stroke) # 

Methods

(==) :: Instrument stroke -> Instrument stroke -> Bool #

(/=) :: Instrument stroke -> Instrument stroke -> Bool #

Show stroke => Show (Instrument stroke) # 

Methods

showsPrec :: Int -> Instrument stroke -> ShowS #

show :: Instrument stroke -> String #

showList :: [Instrument stroke] -> ShowS #

Monoid (Instrument stroke) # 

Methods

mempty :: Instrument stroke #

mappend :: Instrument stroke -> Instrument stroke -> Instrument stroke #

mconcat :: [Instrument stroke] -> Instrument stroke #

Pretty.Pretty stroke => Pretty.Pretty (Instrument stroke) # 

Methods

pretty :: Instrument stroke -> Text Source #

format :: Instrument stroke -> Doc Source #

formatList :: [Instrument stroke] -> Doc Source #

instrument :: Pretty.Pretty stroke => [([S.Note g (Solkattu.Note Solkattu.Sollu)], [SNote stroke])] -> Patterns stroke -> Either Error (Instrument stroke) Source #

realize

type RealizePattern tempo stroke = tempo -> Solkattu.Pattern -> Either Error [(tempo, Note stroke)] Source #

keep_pattern :: RealizePattern tempo stroke Source #

Don't realize Patterns, just pass them through.

type Meta sollu = S.Meta (Solkattu.Group sollu) Source #

realize :: forall stroke sollu. (Pretty.Pretty stroke, Pretty.Pretty sollu) => RealizePattern S.Tempo stroke -> GetStroke sollu stroke -> [(Meta sollu, Solkattu.Note sollu)] -> Either Error [(Meta (Stroke stroke), Note stroke)] Source #

reassociate_strokes :: forall sollu stroke. [(Maybe.Maybe (Meta sollu), Note stroke)] -> [(Meta (Stroke stroke), Note stroke)] Source #

Take strokes with Nothing meta, and put them into the next Meta. The Nothings were added by realize_group out of Solkattu._dropped, so this is putting them back into their groups after being converted to strokes.

add_meta :: S.Tempo -> S.Meta g Source #

Patterns just have (tempo, stroke), no groups, so I add empty groups to merge their result into realize output.

find_sequence :: Pretty.Pretty sollu => GetStroke sollu stroke -> [(meta, Solkattu.Note sollu)] -> Either Error ([(meta, Note stroke)], [(meta, Solkattu.Note sollu)]) Source #

Find the longest matching sequence and return the match and unconsumed notes.

replace_sollus :: [Maybe.Maybe (Stroke stroke)] -> [(meta, Solkattu.Note sollu)] -> ([(meta, Note stroke)], [(meta, Solkattu.Note sollu)]) Source #

Match each stroke to a Sollu, copying over Rests without consuming a stroke.

GetStroke

type GetStroke sollu stroke = (Int, Maybe.Maybe Solkattu.Tag -> [sollu] -> Maybe.Maybe [Maybe.Maybe (Stroke stroke)]) Source #

Int is the longest [sollu] key, so I know when to give up looking for the longest prefix.

best_match :: Maybe.Maybe Solkattu.Tag -> [sollu] -> GetStroke sollu stroke -> Maybe.Maybe [Maybe.Maybe (Stroke stroke)] Source #

exact_match :: Maybe.Maybe Solkattu.Tag -> [sollu] -> GetStroke sollu stroke -> Maybe.Maybe [Maybe.Maybe (Stroke stroke)] Source #

format text

format :: Pretty.Pretty stroke => Maybe.Maybe Int -> Int -> Tala.Tala -> [(S.Meta a, Note stroke)] -> Text Source #

Format the notes according to the tala.

The line breaking for rulers is a bit weird in that if the line is broken, I only emit the first part of the ruler. Otherwise I'd have to have a multiple line ruler too, which might be too much clutter. I'll have to see how it works out in practice.

thin_rests :: [Symbol] -> [Symbol] Source #

Drop single character rests on odd columns, to make the output look less cluttered.

format_final_avartanam :: [[[(a, Symbol)]]] -> [[[(a, Symbol)]]] Source #

If the final non-rest is at sam, drop trailing rests, and don't wrap it onto the next line.

format_lines :: Pretty.Pretty stroke => Int -> Int -> Tala.Tala -> [(S.Meta a, Note stroke)] -> [[[(S.State, Symbol)]]] Source #

Break into [avartanam], where avartanam = [line].

annotate_groups :: [(Maybe.Maybe (S.GroupMark g), (S.State, S.Stroke a))] -> [(S.State, ([StartEnd], S.Stroke a))] Source #

Put StartEnd on the strokes to mark group boundaries.

data StartEnd Source #

Constructors

Start 
End 

break_avartanams :: [(S.State, a)] -> [[(S.State, a)]] Source #

attach_ruler :: [(Text, Text)] -> Text Source #

Strip duplicate rulers and attach to the notation lines. Avartanams which were broken due to width are separated with two newlines to make that visible.

map_with_fst :: (a -> b -> c) -> [(a, b)] -> [(a, c)] Source #

Like second, but also give fst as an argument.

break_line :: Int -> [(S.State, Symbol)] -> [[(S.State, Symbol)]] Source #

If the text goes over the width, break at the middle akshara, or the last one before the width if there isn't a middle.

break_before :: Int -> [(S.State, Symbol)] -> [[(S.State, Symbol)]] Source #

Yet another word-breaking algorithm. I must have 3 or 4 of these by now.

break_fst :: (key -> Bool) -> [(key, a)] -> ([a], [a]) Source #

formatting

data Symbol Source #

Constructors

Symbol 

Fields

Instances

Eq Symbol # 

Methods

(==) :: Symbol -> Symbol -> Bool #

(/=) :: Symbol -> Symbol -> Bool #

Show Symbol # 

format html

write_html :: Pretty.Pretty stroke => FilePath -> Tala.Tala -> [[(S.Meta a, Note stroke)]] -> IO () Source #

format_html :: Pretty.Pretty stroke => Tala.Tala -> [(S.Meta a, Note stroke)] -> Doc.Html Source #

format_table :: Pretty.Pretty stroke => Tala.Tala -> [(S.Meta a, Note stroke)] -> [[(S.State, Doc.Html)]] Source #

util

span_until_just :: [(Maybe.Maybe a, b)] -> ([b], [(Maybe.Maybe a, b)]) Source #

map_until_left :: (a -> [a] -> Either err (b, [a])) -> [a] -> ([b], Maybe.Maybe err) Source #

Apply the function until it returns Left. The function can consume a variable number of elements.