Karya, built on 2023-08-29T07:47:28 (patch 7a412d5d6ba4968ca4155ef276a062ccdeb9109a)
Safe HaskellSafe-Inferred

Solkattu.Realize

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.

Constructors

Note !(Stroke stroke) 
Space !Solkattu.Space 
Abstract !Solkattu.Meta

A pattern that has been made abstract. This is a group that has been abstracted away. That means it can have a name, but also it doesn't have to have an integral matra duration. Since Abstract comes from Notes, the abstract duration is a series of 1-matra Abstracts, where each Note used to be.

These are created at the Format level, not here.

Alignment !Tala.Akshara

This is Solkattu.Alignment. It shouldn't be here, but since I now drop groups in realize via convertGroups, I have to do checkAlignment on the output of realize, which means I need to preserve the Alignments.

Instances

Instances details
Foldable Note Source # 
Instance details

Defined in Solkattu.Realize

Methods

fold :: Monoid m => Note m -> m #

foldMap :: Monoid m => (a -> m) -> Note a -> m #

foldMap' :: Monoid m => (a -> m) -> Note a -> m #

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

foldr' :: (a -> b -> b) -> b -> Note a -> b #

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

foldl' :: (b -> a -> b) -> b -> Note a -> b #

foldr1 :: (a -> a -> a) -> Note a -> a #

foldl1 :: (a -> a -> a) -> Note a -> a #

toList :: Note a -> [a] #

null :: Note a -> Bool #

length :: Note a -> Int #

elem :: Eq a => a -> Note a -> Bool #

maximum :: Ord a => Note a -> a #

minimum :: Ord a => Note a -> a #

sum :: Num a => Note a -> a #

product :: Num a => Note a -> a #

Traversable Note Source # 
Instance details

Defined in Solkattu.Realize

Methods

traverse :: Applicative f => (a -> f b) -> Note a -> f (Note b) #

sequenceA :: Applicative f => Note (f a) -> f (Note a) #

mapM :: Monad m => (a -> m b) -> Note a -> m (Note b) #

sequence :: Monad m => Note (m a) -> m (Note a) #

Functor Note Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Show stroke => Show (Note stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

show :: Note stroke -> String #

showList :: [Note stroke] -> ShowS #

DeepSeq.NFData (Note stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

rnf :: Note stroke -> () #

Eq stroke => Eq (Note stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Rest (SNote sollu) Source # 
Instance details

Defined in Solkattu.Dsl.Notation

Methods

__ :: SNote sollu Source #

S.HasMatras (Note stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

hasSustain :: Note stroke -> Bool Source #

Solkattu.Notation stroke => Solkattu.Notation (Note stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

notation :: Note stroke -> (Styled.Style, Text) Source #

extension :: Note stroke -> Char.Char Source #

Pretty.Pretty stroke => Pretty.Pretty (Note stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: Note stroke -> Text Source #

format :: Note stroke -> Doc Source #

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

mapStroke :: Applicative f => (Stroke a -> f (Stroke b)) -> Note a -> f (Note b) Source #

data Stroke stroke Source #

Constructors

Stroke 

Fields

Instances

Instances details
Foldable Stroke Source # 
Instance details

Defined in Solkattu.Realize

Methods

fold :: Monoid m => Stroke m -> m #

foldMap :: Monoid m => (a -> m) -> Stroke a -> m #

foldMap' :: Monoid m => (a -> m) -> Stroke a -> m #

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

foldr' :: (a -> b -> b) -> b -> Stroke a -> b #

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

foldl' :: (b -> a -> b) -> b -> Stroke a -> b #

foldr1 :: (a -> a -> a) -> Stroke a -> a #

foldl1 :: (a -> a -> a) -> Stroke a -> a #

toList :: Stroke a -> [a] #

null :: Stroke a -> Bool #

length :: Stroke a -> Int #

elem :: Eq a => a -> Stroke a -> Bool #

maximum :: Ord a => Stroke a -> a #

minimum :: Ord a => Stroke a -> a #

sum :: Num a => Stroke a -> a #

product :: Num a => Stroke a -> a #

IsString Sequence Source # 
Instance details

Defined in Solkattu.Dsl.Bol

IsString SequenceM Source # 
Instance details

Defined in Solkattu.Dsl.Solkattu

Traversable Stroke Source # 
Instance details

Defined in Solkattu.Realize

Methods

traverse :: Applicative f => (a -> f b) -> Stroke a -> f (Stroke b) #

sequenceA :: Applicative f => Stroke (f a) -> f (Stroke a) #

mapM :: Monad m => (a -> m b) -> Stroke a -> m (Stroke b) #

sequence :: Monad m => Stroke (m a) -> m (Stroke a) #

Functor Stroke Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Show stroke => Show (Stroke stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

show :: Stroke stroke -> String #

showList :: [Stroke stroke] -> ShowS #

Eq stroke => Eq (Stroke stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Ord stroke => Ord (Stroke stroke) Source # 
Instance details

Defined in Solkattu.Realize

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 #

Expr.ToExpr (Stroke Bol) Source # 
Instance details

Defined in Solkattu.Bol

Expr.ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.KendangPasang

Expr.ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.KendangTunggal

Expr.ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.Mridangam

Expr.ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.Reyong

Expr.ToExpr (Stroke Stroke) Source # 
Instance details

Defined in Solkattu.Instrument.Sargam

Expr.ToExpr (Stroke Solkattu.Sollu) Source # 
Instance details

Defined in Solkattu.Instrument.Konnakol

Solkattu.Notation stroke => Solkattu.Notation (Stroke stroke) Source # 
Instance details

Defined in Solkattu.Realize

Pretty.Pretty stroke => Pretty.Pretty (Stroke stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: Stroke stroke -> Text Source #

format :: Stroke stroke -> Doc Source #

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

data Emphasis Source #

The emphasis will be propagated to the underlying stroke.

Constructors

Light 
Normal 
Heavy 

Instances

Instances details
Monoid Emphasis Source # 
Instance details

Defined in Solkattu.Realize

Semigroup Emphasis Source # 
Instance details

Defined in Solkattu.Realize

Show Emphasis Source # 
Instance details

Defined in Solkattu.Realize

Eq Emphasis Source # 
Instance details

Defined in Solkattu.Realize

Ord Emphasis Source # 
Instance details

Defined in Solkattu.Realize

Pretty.Pretty Emphasis Source # 
Instance details

Defined in Solkattu.Realize

stroke :: stroke -> Stroke stroke Source #

rest :: SNote stroke Source #

doubleRest :: Char.Char Source #

Used to replace two rests.

checkAlignment

data Warning Source #

Stroke index and warning text.

Constructors

Warning (Maybe.Maybe Int) !Text 

Instances

Instances details
Show Warning Source # 
Instance details

Defined in Solkattu.Realize

Eq Warning Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

checkAlignment :: Tala.Akshara -> S.Duration -> S.Duration -> [(S.Tempo, Note stroke)] -> Maybe.Maybe Warning Source #

Verify that the notes start and end at sam, and the given Alignments fall where expected.

checkDuration :: [Realized stroke] -> ([Realized stroke], [Warning]) Source #

Check Solkattu.GCheckDuration, and filter them out.

StrokeMap

data StrokeMap sollu stroke Source #

Sollu to instrument stroke mapping.

I considered integrating both strokes and patterns into SolluMap, but I kind of like how the types for SolluMap and PatternMap can be more specific. Namely, SolluMap has only strokes and rests, because it gets substituted for sollus, regardless of their rhythm, while PatternMap can have tempo changes since they always substitute a single Solkattu.Note. If I ever have a use for e.g. (taka.p5, ...) then I could reconsider.

Constructors

StrokeMap 

Fields

Instances

Instances details
Ord sollu => Monoid (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

mempty :: StrokeMap sollu stroke #

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

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

Ord sollu => Semigroup (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

(<>) :: StrokeMap sollu stroke -> StrokeMap sollu stroke -> StrokeMap sollu stroke #

sconcat :: NonEmpty (StrokeMap sollu stroke) -> StrokeMap sollu stroke #

stimes :: Integral b => b -> StrokeMap sollu stroke -> StrokeMap sollu stroke #

Generics.Generic (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Associated Types

type Generics.Rep (StrokeMap sollu stroke) :: Type -> Type #

Methods

from :: StrokeMap sollu stroke -> Generics.Rep (StrokeMap sollu stroke) x #

to :: Generics.Rep (StrokeMap sollu stroke) x -> StrokeMap sollu stroke #

(Show sollu, Show stroke) => Show (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

show :: StrokeMap sollu stroke -> String #

showList :: [StrokeMap sollu stroke] -> ShowS #

(Eq sollu, Eq stroke) => Eq (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

(Pretty.Pretty sollu, Pretty.Pretty stroke) => Pretty.Pretty (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: StrokeMap sollu stroke -> Text Source #

format :: StrokeMap sollu stroke -> Doc Source #

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

type Generics.Rep (StrokeMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

smapKeys :: StrokeMap sollu stroke -> Set (SolluMapKey sollu) Source #

strokeMap :: (Pretty.Pretty sollu, Ord sollu, Pretty.Pretty stroke) => PatternMap stroke -> [(S.Sequence g (Solkattu.Note sollu), S.Sequence g (Solkattu.Note (Stroke stroke)))] -> Either Error (StrokeMap sollu stroke) Source #

Verify a list of pairs stroke map and put them in an StrokeMap.

solkattuToRealize :: S.Sequence g (Solkattu.Note (Stroke stroke)) -> Either Error [S.Note () (Note stroke)] Source #

Stroke maps use Notes, so they can use the same language in Solkattu.Dsl. But since they don't go through a realization step (being used to implement the realization step for sollus), I can directly map them to Notes before storing them in StrokeMap.

PatternMap

data PatternMap 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 patternMap.

Instances

Instances details
Monoid (PatternMap stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

mempty :: PatternMap stroke #

mappend :: PatternMap stroke -> PatternMap stroke -> PatternMap stroke #

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

Semigroup (PatternMap stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

(<>) :: PatternMap stroke -> PatternMap stroke -> PatternMap stroke #

sconcat :: NonEmpty (PatternMap stroke) -> PatternMap stroke #

stimes :: Integral b => b -> PatternMap stroke -> PatternMap stroke #

Show stroke => Show (PatternMap stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

show :: PatternMap stroke -> String #

showList :: [PatternMap stroke] -> ShowS #

Eq stroke => Eq (PatternMap stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Pretty.Pretty stroke => Pretty.Pretty (PatternMap stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: PatternMap stroke -> Text Source #

format :: PatternMap stroke -> Doc Source #

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

patternMap :: [(Solkattu.Pattern, S.Sequence () (Note stroke))] -> Either Error (PatternMap stroke) Source #

Make a PatternMap while checking that the durations match. Analogous to solluMap.

SolluMap

type SolluMapKey sollu = (Maybe.Maybe Solkattu.Tag, [sollu]) Source #

realize

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

data Group stroke Source #

This is the realized version of Solkattu.Group. I retain the dropped strokes so Solkattu.Technique can use them.

Constructors

GReduction !(Reduction stroke) 
GMeta !Solkattu.Meta 

Instances

Instances details
Functor Group Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Show stroke => Show (Group stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

show :: Group stroke -> String #

showList :: [Group stroke] -> ShowS #

Eq stroke => Eq (Group stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Ord stroke => Ord (Group stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

compare :: Group stroke -> Group stroke -> Ordering #

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

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

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

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

max :: Group stroke -> Group stroke -> Group stroke #

min :: Group stroke -> Group stroke -> Group stroke #

Pretty.Pretty stroke => Pretty.Pretty (Group stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: Group stroke -> Text Source #

format :: Group stroke -> Doc Source #

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

data Reduction stroke Source #

Constructors

Reduction 

Fields

Instances

Instances details
Functor Reduction Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Show stroke => Show (Reduction stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

show :: Reduction stroke -> String #

showList :: [Reduction stroke] -> ShowS #

Eq stroke => Eq (Reduction stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

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

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

Ord stroke => Ord (Reduction stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

compare :: Reduction stroke -> Reduction stroke -> Ordering #

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

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

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

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

max :: Reduction stroke -> Reduction stroke -> Reduction stroke #

min :: Reduction stroke -> Reduction stroke -> Reduction stroke #

Pretty.Pretty stroke => Pretty.Pretty (Reduction stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: Reduction stroke -> Text Source #

format :: Reduction stroke -> Doc Source #

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

realize :: (Pretty.Pretty sollu, Ord sollu) => StrokeMap Solkattu.Sollu stroke -> ToStrokes sollu stroke -> Tala.Akshara -> [S.Flat Solkattu.Group (Solkattu.Note sollu)] -> (UF.UntilFail Error (Realized stroke), Set (SolluMapKey sollu)) Source #

realize_ :: (Pretty.Pretty sollu, Ord sollu) => RealizePattern S.Tempo stroke -> ToStrokes sollu stroke -> Tala.Akshara -> [S.Flat Solkattu.Group (Solkattu.Note sollu)] -> (UF.UntilFail Error (Realized stroke), Set (SolluMapKey sollu)) Source #

ToStroke

data ToStrokes sollu stroke Source #

Find strokes for a sequence of sollus.

realizeStroke :: ToStrokes (Stroke stroke) stroke Source #

If the sollu and stroke are the same, I can just copy the sollu. This is for "monomorphic" single instrument scores, such as for mridangam.

realizeSollu :: Ord sollu => SolluMap sollu stroke -> ToStrokes (Stroke sollu) stroke Source #

Convert Sollus to strokes. The input Sollus have an extra Stroke wrapper. The Stroke is extraneous and is ignored, it's just for uniformity with realizeStroke, since KorvaiSections no longer has a separate case for Sollu which allowed it to omit the Realize.Stroke.

text util

DEBUG

newtype SolluMap sollu stroke Source #

Sollus and Strokes should be the same length. This is enforced in the constructor solluMap. Nothing is a rest, which means a sollu can map to silence, which actually happens in practice.

Constructors

SolluMap (Map (SolluMapKey sollu) [Maybe.Maybe (Stroke stroke)]) 

Instances

Instances details
Ord sollu => Monoid (SolluMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

mempty :: SolluMap sollu stroke #

mappend :: SolluMap sollu stroke -> SolluMap sollu stroke -> SolluMap sollu stroke #

mconcat :: [SolluMap sollu stroke] -> SolluMap sollu stroke #

Ord sollu => Semigroup (SolluMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

(<>) :: SolluMap sollu stroke -> SolluMap sollu stroke -> SolluMap sollu stroke #

sconcat :: NonEmpty (SolluMap sollu stroke) -> SolluMap sollu stroke #

stimes :: Integral b => b -> SolluMap sollu stroke -> SolluMap sollu stroke #

(Show sollu, Show stroke) => Show (SolluMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

showsPrec :: Int -> SolluMap sollu stroke -> ShowS #

show :: SolluMap sollu stroke -> String #

showList :: [SolluMap sollu stroke] -> ShowS #

(Eq sollu, Eq stroke) => Eq (SolluMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

(==) :: SolluMap sollu stroke -> SolluMap sollu stroke -> Bool #

(/=) :: SolluMap sollu stroke -> SolluMap sollu stroke -> Bool #

(Pretty.Pretty sollu, Pretty.Pretty stroke) => Pretty.Pretty (SolluMap sollu stroke) Source # 
Instance details

Defined in Solkattu.Realize

Methods

pretty :: SolluMap sollu stroke -> Text Source #

format :: SolluMap sollu stroke -> Doc Source #

formatList :: [SolluMap sollu stroke] -> Doc Source #

solluMap :: (Pretty.Pretty stroke, Pretty.Pretty sollu, Ord sollu) => [(S.Sequence g (Solkattu.Note sollu), [SNote stroke])] -> Either Error (SolluMap sollu stroke, [(SolluMapKey sollu, [Maybe.Maybe (Stroke stroke)])]) Source #

Verify and costruct a SolluMap from a list of pairs. Later pairs win over earlier ones.

type Realized stroke = S.Flat (Group (Stroke stroke)) (Note stroke) Source #