-- Copyright 2017 Evan Laforge
-- This program is distributed under the terms of the GNU General Public
-- License 3.0, see COPYING or http://www.gnu.org/licenses/gpl-3.0.txt

{-# LANGUAGE RecordWildCards #-}
-- | Global imports for solkattu score modules.
module Solkattu.Dsl.Solkattu (
    module Solkattu.Dsl.Solkattu
    , module Solkattu.Dsl.Generic
    , module Solkattu.Dsl.Interactive
) where
import           Prelude hiding ((.), (^))
import qualified Data.List as List
import qualified Data.Map as Map
import qualified Data.String as String
import qualified Data.Text as Text
import qualified Data.Text.IO as Text.IO

import qualified Util.CallStack as CallStack
import qualified Solkattu.Dsl.Interactive as Interactive
import           Solkattu.Dsl.Interactive (diff, diffw)
import qualified Solkattu.Dsl.MridangamNotation as MridangamNotation
import qualified Solkattu.Format.Terminal as Terminal
import qualified Solkattu.Instrument.KendangPasang as KendangPasang
import qualified Solkattu.Instrument.KendangTunggal as KendangTunggal
import qualified Solkattu.Instrument.Mridangam as Mridangam
import qualified Solkattu.Instrument.Reyong as Reyong
import qualified Solkattu.Instrument.Sargam as Sargam
import qualified Solkattu.Korvai as Korvai
import qualified Solkattu.Realize as Realize
import qualified Solkattu.S as S
import qualified Solkattu.Solkattu as Solkattu
import qualified Solkattu.Tala as Tala

import           Global
import           Solkattu.Dsl.Generic


type Sequence = SequenceT Solkattu.Sollu
type SequenceR stroke = SequenceT (Realize.Stroke stroke)
type SequenceM = SequenceR Mridangam.Stroke

type Section = Korvai.Section Sequence

instance String.IsString Sequence where
    -- Even with InstanceSigs, this doesn't actually work to add a call stack.
    -- fromString :: CallStack.Stack => String -> Sequence
    fromString :: String -> Sequence
fromString String
s = Stack => Text -> Sequence
strS (String -> Text
txt String
s)

instance String.IsString SequenceM where
    fromString :: String -> SequenceM
fromString = Stack => String -> SequenceM
strM

-- | Parse a string to sollus.  Look for syllables inside words.
strS :: CallStack.Stack => Text -> Sequence
strS :: Stack => Text -> Sequence
strS Text
str = forall a. Monoid a => [a] -> a
mconcat forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (forall b a. b -> (a -> b) -> Maybe a -> b
maybe forall a. Rest a => a
__ Sollu -> Sequence
_sollu) forall a b. (a -> b) -> a -> b
$ forall a. Stack => Either Text a -> a
check forall a b. (a -> b) -> a -> b
$ Text -> Either Text [Maybe Sollu]
Solkattu.parseSollus Text
str

-- * sollus

_sollu :: Solkattu.Sollu -> Sequence
_sollu :: Sollu -> Sequence
_sollu Sollu
s = forall g a. Note g a -> Sequence g a
S.singleton forall a b. (a -> b) -> a -> b
$ forall g a. a -> Note g a
S.Note (forall sollu. NoteT sollu -> Note sollu
Solkattu.Note (forall sollu. sollu -> NoteT sollu
Solkattu.note Sollu
s))

cham :: Sequence
cham = Sollu -> Sequence
_sollu Sollu
Solkattu.Cham
dheem :: Sequence
dheem = Sollu -> Sequence
_sollu Sollu
Solkattu.Dheem
dhom :: Sequence
dhom = Sollu -> Sequence
_sollu Sollu
Solkattu.Dhom
di :: Sequence
di = Sollu -> Sequence
_sollu Sollu
Solkattu.Di
din :: Sequence
din = Sollu -> Sequence
_sollu Sollu
Solkattu.Din
dim :: Sequence
dim = Sollu -> Sequence
_sollu Sollu
Solkattu.Dim
dit :: Sequence
dit = Sollu -> Sequence
_sollu Sollu
Solkattu.Dit
du :: Sequence
du = Sollu -> Sequence
_sollu Sollu
Solkattu.Du
ga :: Sequence
ga = Sollu -> Sequence
_sollu Sollu
Solkattu.Ga
gin :: Sequence
gin = Sollu -> Sequence
_sollu Sollu
Solkattu.Gin
gu :: Sequence
gu = Sollu -> Sequence
_sollu Sollu
Solkattu.Gu
jo :: Sequence
jo = Sollu -> Sequence
_sollu Sollu
Solkattu.Jo
ka :: Sequence
ka = Sollu -> Sequence
_sollu Sollu
Solkattu.Ka
ki :: Sequence
ki = Sollu -> Sequence
_sollu Sollu
Solkattu.Ki
ku :: Sequence
ku = Sollu -> Sequence
_sollu Sollu
Solkattu.Ku
kum :: Sequence
kum = Sollu -> Sequence
_sollu Sollu
Solkattu.Kum
mi :: Sequence
mi = Sollu -> Sequence
_sollu Sollu
Solkattu.Mi
na :: Sequence
na = Sollu -> Sequence
_sollu Sollu
Solkattu.Na
nam :: Sequence
nam = Sollu -> Sequence
_sollu Sollu
Solkattu.Nam
nang :: Sequence
nang = Sollu -> Sequence
_sollu Sollu
Solkattu.Nang
nu :: Sequence
nu = Sollu -> Sequence
_sollu Sollu
Solkattu.Nu
ri :: Sequence
ri = Sollu -> Sequence
_sollu Sollu
Solkattu.Ri
ta :: Sequence
ta = Sollu -> Sequence
_sollu Sollu
Solkattu.Ta
tam :: Sequence
tam = Sollu -> Sequence
_sollu Sollu
Solkattu.Tam
tat :: Sequence
tat = Sollu -> Sequence
_sollu Sollu
Solkattu.Tat
tha :: Sequence
tha = Sollu -> Sequence
_sollu Sollu
Solkattu.Tha
thom :: Sequence
thom = Sollu -> Sequence
_sollu Sollu
Solkattu.Thom
ti :: Sequence
ti = Sollu -> Sequence
_sollu Sollu
Solkattu.Ti

tang :: Sequence
tang = Sollu -> Sequence
_sollu Sollu
Solkattu.Tang
tong :: Sequence
tong = Sollu -> Sequence
_sollu Sollu
Solkattu.Tong
lang :: Sequence
lang = Sollu -> Sequence
_sollu Sollu
Solkattu.Lang

-- * fragments

-- TODO these should be namedT Solkattu.GPattern "p#", but that makes
-- 'spread' not work.
tdgnt, td_gnt, t_d_gnt :: Sequence
tdgnt :: Sequence
tdgnt = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
dinforall a. Monoid a => a -> a -> a
.Sequence
ginforall a. Monoid a => a -> a -> a
.Sequence
naforall a. Monoid a => a -> a -> a
.Sequence
thom
td_gnt :: Sequence
td_gnt = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
dinforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
ginforall a. Monoid a => a -> a -> a
.Sequence
naforall a. Monoid a => a -> a -> a
.Sequence
thom
t_d_gnt :: Sequence
t_d_gnt = Sequence
taforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
dinforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
ginforall a. Monoid a => a -> a -> a
.Sequence
naforall a. Monoid a => a -> a -> a
.Sequence
thom

takadinna, takita, kita, taka, tiku, diku, tari, gugu, dugu :: Sequence
takadinna :: Sequence
takadinna = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
kaforall a. Monoid a => a -> a -> a
.Sequence
dinforall a. Monoid a => a -> a -> a
.Sequence
na
takita :: Sequence
takita = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
kiforall a. Monoid a => a -> a -> a
.Sequence
ta
kita :: Sequence
kita = Sequence
kiforall a. Monoid a => a -> a -> a
.Sequence
ta
taka :: Sequence
taka = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
ka
naka :: Sequence
naka = Sequence
naforall a. Monoid a => a -> a -> a
.Sequence
ka
tiku :: Sequence
tiku = Sequence
tiforall a. Monoid a => a -> a -> a
.Sequence
ku
diku :: Sequence
diku = Sequence
diforall a. Monoid a => a -> a -> a
.Sequence
ku
tari :: Sequence
tari = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
ri
gugu :: Sequence
gugu = Sequence
guforall a. Monoid a => a -> a -> a
.Sequence
gu
dugu :: Sequence
dugu = Sequence
duforall a. Monoid a => a -> a -> a
.Sequence
gu

jonu :: Sequence
jonu :: Sequence
jonu = Sequence
joforall a. Monoid a => a -> a -> a
.Sequence
nu

kitataka, tarikita, tadikita :: Sequence
kitataka :: Sequence
kitataka = Sequence
kitaforall a. Monoid a => a -> a -> a
.Sequence
taka
tarikita :: Sequence
tarikita = Sequence
tariforall a. Monoid a => a -> a -> a
.Sequence
kita
tadikita :: Sequence
tadikita = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
diforall a. Monoid a => a -> a -> a
.Sequence
kiforall a. Monoid a => a -> a -> a
.Sequence
ta

talang, talanga :: Sequence
talang :: Sequence
talang = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
lang
talanga :: Sequence
talanga = Sequence
taforall a. Monoid a => a -> a -> a
.Sequence
langa

dinga, dingu, tanga, langa :: Sequence
dinga :: Sequence
dinga = Sequence
dinforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
ga
dingu :: Sequence
dingu = Sequence
dinforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
gu
tanga :: Sequence
tanga = Sequence
tangforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
ga
langa :: Sequence
langa = Sequence
langforall a. Monoid a => a -> a -> a
.forall a. Rest a => a
__forall a. Monoid a => a -> a -> a
.Sequence
ga

-- ** fast variants

kt, tk, tkt, tkdn, trkt, kttk :: Sequence
kt :: Sequence
kt = forall g sollu. Sequence g sollu -> Sequence g sollu
su Sequence
kita
tk :: Sequence
tk = forall g sollu. Sequence g sollu -> Sequence g sollu
su Sequence
taka
tkt :: Sequence
tkt = forall g sollu. Sequence g sollu -> Sequence g sollu
su Sequence
takita
tkdn :: Sequence
tkdn = forall g sollu. Sequence g sollu -> Sequence g sollu
su Sequence
takadinna
trkt :: Sequence
trkt = forall g sollu. Sequence g sollu -> Sequence g sollu
su Sequence
tarikita
kttk :: Sequence
kttk = forall g sollu. Sequence g sollu -> Sequence g sollu
su Sequence
kitataka

-- ** standard fragments

-- It's awkward that these use mridangam fingerings instead of solkattu, but
-- the solkattu are otherwise ambiguous, and too long anyway.  I originally
-- used solkattu without vowels, but later I wanted to use the same names for
-- fast variants.

kp, kpnp :: Sequence
kp :: Sequence
kp = forall sollu.
GroupType -> Text -> SequenceT sollu -> SequenceT sollu
namedT GroupType
Solkattu.GFiller Text
"2t" (Tag
Solkattu.Standard forall sollu. Tag -> SequenceT sollu -> SequenceT sollu
^ Sequence
taka)
kpnp :: Sequence
kpnp = forall sollu.
GroupType -> Text -> SequenceT sollu -> SequenceT sollu
namedT GroupType
Solkattu.GFiller Text
"4t" (Tag
Solkattu.Standard forall sollu. Tag -> SequenceT sollu -> SequenceT sollu
^ (Sequence
takaforall a. Monoid a => a -> a -> a
.Sequence
tiku))

-- These are more problematic because different realizations are common, e.g.
-- oktp, pktp.
oknp, ktktoknp :: Sequence
oknp :: Sequence
oknp = forall sollu.
GroupType -> Text -> SequenceT sollu -> SequenceT sollu
namedT GroupType
Solkattu.GFiller Text
"4t" forall a b. (a -> b) -> a -> b
$ Tag
Solkattu.Standard forall sollu. Tag -> SequenceT sollu -> SequenceT sollu
^ Sequence
tarikita
ktktoknp :: Sequence
ktktoknp = forall sollu.
GroupType -> Text -> SequenceT sollu -> SequenceT sollu
namedT GroupType
Solkattu.GFiller Text
"8t" forall a b. (a -> b) -> a -> b
$
    Tag
Solkattu.Standard forall sollu. Tag -> SequenceT sollu -> SequenceT sollu
^ (Sequence
tarikitaforall a. Monoid a => a -> a -> a
.Sequence
takaforall a. Monoid a => a -> a -> a
.Sequence
taka)

nakatiku :: Sequence
nakatiku :: Sequence
nakatiku = forall sollu.
GroupType -> Text -> SequenceT sollu -> SequenceT sollu
namedT GroupType
Solkattu.GPattern Text
"8n" forall a b. (a -> b) -> a -> b
$
    Tag
Solkattu.Standard forall sollu. Tag -> SequenceT sollu -> SequenceT sollu
^ (Sequence
nakaforall a. Monoid a => a -> a -> a
.Sequence
tikuforall a. Monoid a => a -> a -> a
.Sequence
tariforall a. Monoid a => a -> a -> a
.Sequence
kita)
    -- also diku.tari.kita.taka

takadugutarikita :: Sequence
takadugutarikita :: Sequence
takadugutarikita = forall sollu.
GroupType -> Text -> SequenceT sollu -> SequenceT sollu
namedT GroupType
Solkattu.GPattern Text
"8t" forall a b. (a -> b) -> a -> b
$
    Tag
Solkattu.Standard forall sollu. Tag -> SequenceT sollu -> SequenceT sollu
^ (Sequence
takaforall a. Monoid a => a -> a -> a
.Sequence
duguforall a. Monoid a => a -> a -> a
.Sequence
tariforall a. Monoid a => a -> a -> a
.Sequence
kita)

-- * instruments

Mridangam.Strokes {Sequence g (Note (Stroke Stroke))
od :: Sequence g (Note (Stroke Stroke))
_' :: Sequence g (Note (Stroke Stroke))
o' :: Sequence g (Note (Stroke Stroke))
o :: Sequence g (Note (Stroke Stroke))
p' :: Sequence g (Note (Stroke Stroke))
p :: Sequence g (Note (Stroke Stroke))
j :: Sequence g (Note (Stroke Stroke))
y :: Sequence g (Note (Stroke Stroke))
i :: Sequence g (Note (Stroke Stroke))
v :: Sequence g (Note (Stroke Stroke))
u :: Sequence g (Note (Stroke Stroke))
d :: Sequence g (Note (Stroke Stroke))
n :: Sequence g (Note (Stroke Stroke))
l :: Sequence g (Note (Stroke Stroke))
t :: Sequence g (Note (Stroke Stroke))
k :: Sequence g (Note (Stroke Stroke))
od :: forall a. Strokes a -> a
_' :: forall a. Strokes a -> a
o' :: forall a. Strokes a -> a
o :: forall a. Strokes a -> a
p' :: forall a. Strokes a -> a
p :: forall a. Strokes a -> a
j :: forall a. Strokes a -> a
y :: forall a. Strokes a -> a
i :: forall a. Strokes a -> a
v :: forall a. Strokes a -> a
u :: forall a. Strokes a -> a
d :: forall a. Strokes a -> a
n :: forall a. Strokes a -> a
l :: forall a. Strokes a -> a
t :: forall a. Strokes a -> a
k :: forall a. Strokes a -> a
..} = forall g. Strokes (Sequence g (Note (Stroke Stroke)))
Mridangam.notes

-- | Merge a sequence of left hand strokes with one of right hand strokes.
-- Both sequences must have the same length and structure.
(&) :: CallStack.Stack => SequenceM -> SequenceM -> SequenceM
SequenceM
a & :: Stack => SequenceM -> SequenceM -> SequenceM
& SequenceM
b = forall g a. [Note g a] -> Sequence g a
S.fromList forall a b. (a -> b) -> a -> b
$ Stack =>
[NoteT (Stroke Stroke)]
-> [NoteT (Stroke Stroke)] -> [NoteT (Stroke Stroke)]
MridangamNotation.merge (forall g a. Sequence g a -> [Note g a]
S.toList SequenceM
a) (forall g a. Sequence g a -> [Note g a]
S.toList SequenceM
b)

on :: SequenceM
on :: SequenceM
on = forall {g}. Sequence g (Note (Stroke Stroke))
oStack => SequenceM -> SequenceM -> SequenceM
&forall {g}. Sequence g (Note (Stroke Stroke))
n

-- | Parse a string to mridangam strokes.
strM :: CallStack.Stack => String -> SequenceM
strM :: Stack => String -> SequenceM
strM String
str = forall b a. Monoid b => (a -> b) -> [a] -> b
mconcatMap forall {g} {stroke}.
Rest (Sequence g (Note (Stroke stroke))) =>
Maybe stroke -> Sequence g (Note (Stroke stroke))
toSeq forall a b. (a -> b) -> a -> b
$ forall a. Stack => Either Text a -> a
Solkattu.check forall a b. (a -> b) -> a -> b
$ String -> Either Text [Maybe Stroke]
Mridangam.fromString String
str
    where
    toSeq :: Maybe stroke -> Sequence g (Note (Stroke stroke))
toSeq Maybe stroke
Nothing = forall a. Rest a => a
__
    toSeq (Just stroke
stroke) = forall stroke g. stroke -> Sequence g (Note (Stroke stroke))
Realize.strokeToSequence stroke
stroke

type StrokeMap stroke =
    [ ( Sequence
      , S.Sequence Solkattu.Group (Solkattu.Note (Realize.Stroke stroke))
      )
    ]

makeMridangam :: StrokeMap Mridangam.Stroke -> Korvai.StrokeMaps
makeMridangam :: StrokeMap Stroke -> StrokeMaps
makeMridangam StrokeMap Stroke
strokes = StrokeMap Stroke -> StrokeMaps
makeMridangam0 (StrokeMap Stroke
_mridangamStrokes forall a. [a] -> [a] -> [a]
++ StrokeMap Stroke
strokes)

-- | Make a mridangam StrokeMap, but without the default '_mridangamStrokes'.
makeMridangam0 :: StrokeMap Mridangam.Stroke -> Korvai.StrokeMaps
makeMridangam0 :: StrokeMap Stroke -> StrokeMaps
makeMridangam0 StrokeMap Stroke
strokes = forall a. Monoid a => a
mempty
    { smapMridangam :: StrokeMap Sollu Stroke
Korvai.smapMridangam = forall sollu stroke g.
(Pretty sollu, Ord sollu, Pretty stroke) =>
PatternMap stroke
-> [(Sequence g (Note sollu), Sequence g (Note (Stroke stroke)))]
-> Either Text (StrokeMap sollu stroke)
Realize.strokeMap PatternMap Stroke
Mridangam.defaultPatterns StrokeMap Stroke
strokes
    }

-- | Show shadowed strokes in the stroke map.
lintM :: Korvai.Korvai -> IO ()
lintM :: Korvai -> IO ()
lintM = forall stroke x.
Pretty stroke =>
Instrument stroke -> [(Sequence, x)] -> Korvai -> IO ()
_printLint Instrument Stroke
Korvai.IMridangam StrokeMap Stroke
_mridangamStrokes

makeKendang1 :: StrokeMap KendangTunggal.Stroke -> Korvai.StrokeMaps
makeKendang1 :: StrokeMap Stroke -> StrokeMaps
makeKendang1 StrokeMap Stroke
strokes = forall a. Monoid a => a
mempty
    { smapKendangTunggal :: StrokeMap Sollu Stroke
Korvai.smapKendangTunggal =
        forall sollu stroke g.
(Pretty sollu, Ord sollu, Pretty stroke) =>
PatternMap stroke
-> [(Sequence g (Note sollu), Sequence g (Note (Stroke stroke)))]
-> Either Text (StrokeMap sollu stroke)
Realize.strokeMap PatternMap Stroke
KendangTunggal.defaultPatterns
            (StrokeMap Stroke
_kendangStrokes1 forall a. [a] -> [a] -> [a]
++ StrokeMap Stroke
strokes)
    }

lintK1 :: Korvai -> IO ()
lintK1 :: Korvai -> IO ()
lintK1 = forall stroke x.
Pretty stroke =>
Instrument stroke -> [(Sequence, x)] -> Korvai -> IO ()
_printLint Instrument Stroke
Korvai.IKendangTunggal StrokeMap Stroke
_kendangStrokes1

makeKendang2 :: StrokeMap KendangPasang.Stroke -> Korvai.StrokeMaps
makeKendang2 :: StrokeMap Stroke -> StrokeMaps
makeKendang2 StrokeMap Stroke
strokes = forall a. Monoid a => a
mempty
    { smapKendangPasang :: StrokeMap Sollu Stroke
Korvai.smapKendangPasang =
        forall sollu stroke g.
(Pretty sollu, Ord sollu, Pretty stroke) =>
PatternMap stroke
-> [(Sequence g (Note sollu), Sequence g (Note (Stroke stroke)))]
-> Either Text (StrokeMap sollu stroke)
Realize.strokeMap PatternMap Stroke
KendangPasang.defaultPatterns
            (StrokeMap Stroke
_kendangStrokes2 forall a. [a] -> [a] -> [a]
++ StrokeMap Stroke
strokes)
    }

lintK2 :: Korvai -> IO ()
lintK2 :: Korvai -> IO ()
lintK2 = forall stroke x.
Pretty stroke =>
Instrument stroke -> [(Sequence, x)] -> Korvai -> IO ()
_printLint Instrument Stroke
Korvai.IKendangTunggal StrokeMap Stroke
_kendangStrokes2

makeReyong :: StrokeMap Reyong.Stroke -> Korvai.StrokeMaps
makeReyong :: StrokeMap Stroke -> StrokeMaps
makeReyong StrokeMap Stroke
strokes = forall a. Monoid a => a
mempty
    { smapReyong :: StrokeMap Sollu Stroke
Korvai.smapReyong = forall sollu stroke g.
(Pretty sollu, Ord sollu, Pretty stroke) =>
PatternMap stroke
-> [(Sequence g (Note sollu), Sequence g (Note (Stroke stroke)))]
-> Either Text (StrokeMap sollu stroke)
Realize.strokeMap
        PatternMap Stroke
Reyong.rhythmicPatterns (StrokeMap Stroke
_reyongStrokes forall a. [a] -> [a] -> [a]
++ StrokeMap Stroke
strokes)
    }

lintR :: Korvai -> IO ()
lintR :: Korvai -> IO ()
lintR = forall stroke x.
Pretty stroke =>
Instrument stroke -> [(Sequence, x)] -> Korvai -> IO ()
_printLint Instrument Stroke
Korvai.IReyong StrokeMap Stroke
_reyongStrokes

makeSargam :: [(S.Matra, SequenceR Sargam.Stroke)]
    -> StrokeMap Sargam.Stroke -> Korvai.StrokeMaps
makeSargam :: [(Matra, SequenceR Stroke)] -> StrokeMap Stroke -> StrokeMaps
makeSargam [(Matra, SequenceR Stroke)]
patterns StrokeMap Stroke
strokes = forall a. Monoid a => a
mempty { smapSargam :: StrokeMap Sollu Stroke
Korvai.smapSargam = StrokeMap Sollu Stroke
convert }
    where
    convert :: StrokeMap Sollu Stroke
convert = do
        [(Pattern, [Note () (Note Stroke)])]
patterns <- forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse forall g stroke.
Sequence g (Note (Stroke stroke))
-> Either Text [Note () (Note stroke)]
Realize.solkattuToRealize) forall a b. (a -> b) -> a -> b
$
            forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first Matra -> Pattern
Solkattu.pattern) [(Matra, SequenceR Stroke)]
patterns
        PatternMap Stroke
pmap <- forall stroke.
[(Pattern, Sequence () (Note stroke))]
-> Either Text (PatternMap stroke)
Realize.patternMap forall a b. (a -> b) -> a -> b
$ forall a b. (a -> b) -> [a] -> [b]
map (forall (p :: * -> * -> *) b c a.
Bifunctor p =>
(b -> c) -> p a b -> p a c
second forall g a. [Note g a] -> Sequence g a
S.fromList) [(Pattern, [Note () (Note Stroke)])]
patterns
        forall sollu stroke g.
(Pretty sollu, Ord sollu, Pretty stroke) =>
PatternMap stroke
-> [(Sequence g (Note sollu), Sequence g (Note (Stroke stroke)))]
-> Either Text (StrokeMap sollu stroke)
Realize.strokeMap PatternMap Stroke
pmap StrokeMap Stroke
strokes

lintS :: Korvai -> IO ()
lintS :: Korvai -> IO ()
lintS = forall stroke x.
Pretty stroke =>
Instrument stroke -> [(Sequence, x)] -> Korvai -> IO ()
_printLint Instrument Stroke
Korvai.ISargam []

_defaultStrokes :: Korvai.Instrument stroke -> [Sequence]
_defaultStrokes :: forall stroke. Instrument stroke -> [Sequence]
_defaultStrokes Instrument stroke
inst = forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault [] (forall stroke. Instrument stroke -> Text
Korvai.instrumentName Instrument stroke
inst)
    Map Text [Sequence]
_instrumentDefaultStrokes

lintAll :: Korvai -> IO ()
lintAll :: Korvai -> IO ()
lintAll = Text -> IO ()
Text.IO.putStr forall b c a. (b -> c) -> (a -> b) -> a -> c
 Korvai -> Text
allLints

allLints :: Korvai -> Text
allLints :: Korvai -> Text
allLints Korvai
korvai =
    [Text] -> Text
Text.unlines forall a b. (a -> b) -> a -> b
$ forall a. a -> [a] -> [a]
List.intersperse Text
"" forall a b. (a -> b) -> a -> b
$
        forall a b. (a -> Maybe b) -> [a] -> [b]
mapMaybe GInstrument -> Maybe Text
lintsOf (Korvai -> [GInstrument]
Korvai.korvaiInstruments Korvai
korvai)
    where
    lintsOf :: GInstrument -> Maybe Text
lintsOf (Korvai.GInstrument Instrument stroke
inst)
        | Text -> Bool
Text.null Text
warn = forall a. Maybe a
Nothing
        | Bool
otherwise = forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ Text
"    " forall a. Semigroup a => a -> a -> a
<> Text
name forall a. Semigroup a => a -> a -> a
<> Text
":\n" forall a. Semigroup a => a -> a -> a
<> Text
warn
        where
        warn :: Text
warn = forall stroke.
Pretty stroke =>
Instrument stroke -> [Sequence] -> Korvai -> Text
Korvai.lint Instrument stroke
inst (Text -> [Sequence]
get Text
name) Korvai
korvai
        name :: Text
name = forall stroke. Instrument stroke -> Text
Korvai.instrumentName Instrument stroke
inst
    get :: Text -> [Sequence]
get Text
name = forall k a. Ord k => a -> k -> Map k a -> a
Map.findWithDefault [] Text
name Map Text [Sequence]
_instrumentDefaultStrokes

-- | 'makeMridangam' gives this to all mridangam stroke maps.
_mridangamStrokes :: [(Sequence, SequenceM)]
_mridangamStrokes :: StrokeMap Stroke
_mridangamStrokes =
    [ (Sequence
thom, forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
dhom, forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
tang, forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
lang, forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
cham, forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
talang, forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
takadinna, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
k)
    , (Sequence
tdgnt, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
nforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
kp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p)
    , (Sequence
kpnp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
nforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p)
    , (Sequence
oknp, forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
nforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p) -- fast version: pktp
    , (Sequence
ktktoknp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
nforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p)
    , (Sequence
nakatiku, forall {g}. Sequence g (Note (Stroke Stroke))
nforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
uforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
k)
        -- alternate: t.p.u.p.k.t.p.k
        -- alternate: t.p.u.o.k.t.p.k
    , (Sequence
takadugutarikita, forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
k)
    ]
    where Mridangam.Strokes {Sequence g (Note (Stroke Stroke))
od :: Sequence g (Note (Stroke Stroke))
_' :: Sequence g (Note (Stroke Stroke))
o' :: Sequence g (Note (Stroke Stroke))
p' :: Sequence g (Note (Stroke Stroke))
j :: Sequence g (Note (Stroke Stroke))
y :: Sequence g (Note (Stroke Stroke))
i :: Sequence g (Note (Stroke Stroke))
v :: Sequence g (Note (Stroke Stroke))
d :: Sequence g (Note (Stroke Stroke))
l :: Sequence g (Note (Stroke Stroke))
n :: Sequence g (Note (Stroke Stroke))
t :: Sequence g (Note (Stroke Stroke))
k :: Sequence g (Note (Stroke Stroke))
p :: Sequence g (Note (Stroke Stroke))
u :: Sequence g (Note (Stroke Stroke))
o :: Sequence g (Note (Stroke Stroke))
od :: forall a. Strokes a -> a
_' :: forall a. Strokes a -> a
o' :: forall a. Strokes a -> a
o :: forall a. Strokes a -> a
p' :: forall a. Strokes a -> a
p :: forall a. Strokes a -> a
j :: forall a. Strokes a -> a
y :: forall a. Strokes a -> a
i :: forall a. Strokes a -> a
v :: forall a. Strokes a -> a
u :: forall a. Strokes a -> a
d :: forall a. Strokes a -> a
n :: forall a. Strokes a -> a
l :: forall a. Strokes a -> a
t :: forall a. Strokes a -> a
k :: forall a. Strokes a -> a
..} = forall g. Strokes (Sequence g (Note (Stroke Stroke)))
Mridangam.notes

_kendangStrokes1 :: [(Sequence, SequenceR KendangTunggal.Stroke)]
_kendangStrokes1 :: StrokeMap Stroke
_kendangStrokes1 =
    [ (Sequence
thom, forall {g}. Sequence g (Note (Stroke Stroke))
a)
    , (Sequence
tang, forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
lang, forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
cham, forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
talang, forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
takadinna, forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p)
    , (Sequence
tdgnt, forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
a)
    , (Sequence
kp, forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
k)
    , (Sequence
kpnp, forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
k)
    , (Sequence
oknp, forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
ktktoknp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
nakatiku, forall {g}. Sequence g (Note (Stroke Stroke))
KendangTunggal.nakatiku)
    , (Sequence
takadugutarikita, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
t)
    ]
    where KendangTunggal.Strokes {Sequence g (Note (Stroke Stroke))
a :: forall a. Strokes a -> a
o :: forall a. Strokes a -> a
k :: forall a. Strokes a -> a
å :: forall a. Strokes a -> a
u :: forall a. Strokes a -> a
t :: forall a. Strokes a -> a
p :: forall a. Strokes a -> a
pk :: forall a. Strokes a -> a
å :: Sequence g (Note (Stroke Stroke))
pk :: Sequence g (Note (Stroke Stroke))
t :: Sequence g (Note (Stroke Stroke))
k :: Sequence g (Note (Stroke Stroke))
p :: Sequence g (Note (Stroke Stroke))
o :: Sequence g (Note (Stroke Stroke))
u :: Sequence g (Note (Stroke Stroke))
a :: Sequence g (Note (Stroke Stroke))
..} = forall g. Strokes (Sequence g (Note (Stroke Stroke)))
KendangTunggal.notes

_kendangStrokes2 :: [(Sequence, SequenceR KendangPasang.Stroke)]
_kendangStrokes2 :: StrokeMap Stroke
_kendangStrokes2 =
    [ (Sequence
thom, forall {g}. Sequence g (Note (Stroke Stroke))
a)
    , (Sequence
tang, forall {g}. Sequence g (Note (Stroke Stroke))
y)
    , (Sequence
lang, forall {g}. Sequence g (Note (Stroke Stroke))
y)
    , (Sequence
cham, forall {g}. Sequence g (Note (Stroke Stroke))
y)
    , (Sequence
talang, forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
u)
    , (Sequence
takadinna, forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
k)
    , (Sequence
tdgnt, forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
lforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
a)
    , (Sequence
kp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p)
    , (Sequence
kpnp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
l)
    , (Sequence
oknp, forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
lforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
a)
    , (Sequence
ktktoknp, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
oforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
lforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
a)
    , (Sequence
nakatiku, forall {g}. Sequence g (Note (Stroke Stroke))
KendangPasang.nakatiku)
    , (Sequence
takadugutarikita, forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
pforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
aforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
tforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
lforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
kforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
p)
    ]
    where KendangPasang.Strokes {Sequence g (Note (Stroke Stroke))
o :: forall a. Strokes a -> a
a :: forall a. Strokes a -> a
yy :: forall a. Strokes a -> a
y :: forall a. Strokes a -> a
u :: forall a. Strokes a -> a
l :: forall a. Strokes a -> a
t :: forall a. Strokes a -> a
p :: forall a. Strokes a -> a
k :: forall a. Strokes a -> a
pk :: forall a. Strokes a -> a
yy :: Sequence g (Note (Stroke Stroke))
pk :: Sequence g (Note (Stroke Stroke))
t :: Sequence g (Note (Stroke Stroke))
l :: Sequence g (Note (Stroke Stroke))
k :: Sequence g (Note (Stroke Stroke))
o :: Sequence g (Note (Stroke Stroke))
p :: Sequence g (Note (Stroke Stroke))
u :: Sequence g (Note (Stroke Stroke))
y :: Sequence g (Note (Stroke Stroke))
a :: Sequence g (Note (Stroke Stroke))
..} = forall g. Strokes (Sequence g (Note (Stroke Stroke)))
KendangPasang.notes

_reyongStrokes :: [(Sequence, SequenceR Reyong.Stroke)]
_reyongStrokes :: StrokeMap Stroke
_reyongStrokes =
    [ (Sequence
thom, forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
tang, forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
lang, forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
cham, forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
talang, forall {g}. Sequence g (Note (Stroke Stroke))
bforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
o)
    , (Sequence
nakatiku, forall {g}. Sequence g (Note (Stroke Stroke))
iforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
r3forall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
iforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
r2forall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
r3forall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
iforall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
r3forall a. Monoid a => a -> a -> a
.forall {g}. Sequence g (Note (Stroke Stroke))
r2)
        -- TODO melodic version, there could also be a rhythmic version
    ]
    where Reyong.Strokes {Sequence g (Note (Stroke Stroke))
x :: forall a. Strokes a -> a
k :: forall a. Strokes a -> a
o :: forall a. Strokes a -> a
b :: forall a. Strokes a -> a
i :: forall a. Strokes a -> a
r4 :: forall a. Strokes a -> a
r3 :: forall a. Strokes a -> a
r2 :: forall a. Strokes a -> a
r1 :: forall a. Strokes a -> a
x :: Sequence g (Note (Stroke Stroke))
k :: Sequence g (Note (Stroke Stroke))
r4 :: Sequence g (Note (Stroke Stroke))
r1 :: Sequence g (Note (Stroke Stroke))
r2 :: Sequence g (Note (Stroke Stroke))
r3 :: Sequence g (Note (Stroke Stroke))
i :: Sequence g (Note (Stroke Stroke))
b :: Sequence g (Note (Stroke Stroke))
o :: Sequence g (Note (Stroke Stroke))
..} = forall g. Strokes (Sequence g (Note (Stroke Stroke)))
Reyong.notes

_printLint :: Pretty stroke => Korvai.Instrument stroke -> [(Sequence, x)]
    -> Korvai -> IO ()
_printLint :: forall stroke x.
Pretty stroke =>
Instrument stroke -> [(Sequence, x)] -> Korvai -> IO ()
_printLint Instrument stroke
inst [(Sequence, x)]
strokes Korvai
korvai =
    Text -> IO ()
Text.IO.putStr forall a b. (a -> b) -> a -> b
$ forall stroke.
Pretty stroke =>
Instrument stroke -> [Sequence] -> Korvai -> Text
Korvai.lint Instrument stroke
inst (forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(Sequence, x)]
strokes) Korvai
korvai

_instrumentDefaultStrokes :: Map Text [Sequence]
_instrumentDefaultStrokes :: Map Text [Sequence]
_instrumentDefaultStrokes = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList
    [ forall stroke x.
Instrument stroke -> [(Sequence, x)] -> (Text, [Sequence])
pair Instrument Stroke
Korvai.IMridangam StrokeMap Stroke
_mridangamStrokes
    , forall stroke x.
Instrument stroke -> [(Sequence, x)] -> (Text, [Sequence])
pair Instrument Stroke
Korvai.IKendangTunggal StrokeMap Stroke
_kendangStrokes1
    , forall stroke x.
Instrument stroke -> [(Sequence, x)] -> (Text, [Sequence])
pair Instrument Stroke
Korvai.IKendangPasang StrokeMap Stroke
_kendangStrokes2
    , forall stroke x.
Instrument stroke -> [(Sequence, x)] -> (Text, [Sequence])
pair Instrument Stroke
Korvai.IReyong StrokeMap Stroke
_reyongStrokes
    ]
    where
    pair :: Korvai.Instrument stroke -> [(Sequence, x)] -> (Text, [Sequence])
    pair :: forall stroke x.
Instrument stroke -> [(Sequence, x)] -> (Text, [Sequence])
pair Instrument stroke
inst [(Sequence, x)]
strokes = (forall stroke. Instrument stroke -> Text
Korvai.instrumentName Instrument stroke
inst, forall a b. (a -> b) -> [a] -> [b]
map forall a b. (a, b) -> a
fst [(Sequence, x)]
strokes)

-- * realize

realize, realizep :: Korvai.Korvai -> IO ()
realize :: Korvai -> IO ()
realize = (Config -> Config) -> Korvai -> IO ()
realizeM Config -> Config
concrete
realizep :: Korvai -> IO ()
realizep = (Config -> Config) -> Korvai -> IO ()
realizeM forall a. a -> a
id

-- The actual Config transformers are in Generic.

realizeM :: (Terminal.Config -> Terminal.Config) -> Korvai.Korvai -> IO ()
realizeM :: (Config -> Config) -> Korvai -> IO ()
realizeM = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.IMridangam

realizek, realizekp :: Korvai.Korvai -> IO ()
realizek :: Korvai -> IO ()
realizek = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.IKendangTunggal Config -> Config
concrete
realizekp :: Korvai -> IO ()
realizekp = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.IKendangTunggal forall a. a -> a
id

realizek2, realizek2p :: Korvai.Korvai -> IO ()
realizek2 :: Korvai -> IO ()
realizek2 = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.IKendangPasang Config -> Config
concrete
realizek2p :: Korvai -> IO ()
realizek2p = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.IKendangPasang forall a. a -> a
id

realizeWadon :: Korvai.Korvai -> IO ()
realizeWadon :: Korvai -> IO ()
realizeWadon = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument (forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
 Stroke Stroke -> Stroke Stroke
KendangPasang.toWadon)
    Instrument Stroke
Korvai.IKendangPasang Config -> Config
concrete

realizeLanang :: Korvai.Korvai -> IO ()
realizeLanang :: Korvai -> IO ()
realizeLanang = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument (forall a. a -> Maybe a
Just forall b c a. (b -> c) -> (a -> b) -> a -> c
 Stroke Stroke -> Stroke Stroke
KendangPasang.toLanang)
    Instrument Stroke
Korvai.IKendangPasang Config -> Config
concrete

realizeR :: (Terminal.Config -> Terminal.Config) -> Korvai.Korvai -> IO ()
realizeR :: (Config -> Config) -> Korvai -> IO ()
realizeR = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.IReyong

realizeSargam :: (Terminal.Config -> Terminal.Config) -> Korvai.Korvai -> IO ()
realizeSargam :: (Config -> Config) -> Korvai -> IO ()
realizeSargam = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument forall a. a -> Maybe a
Just Instrument Stroke
Korvai.ISargam

realizeKon :: Korvai -> IO ()
realizeKon :: Korvai -> IO ()
realizeKon = Config -> Korvai -> IO ()
Terminal.printKonnakol (Config -> Config
wider Config
Terminal.defaultConfig)

realizeKon_ :: Int -> Korvai -> IO ()
realizeKon_ :: Matra -> Korvai -> IO ()
realizeKon_ Matra
width = Config -> Korvai -> IO ()
Terminal.printKonnakol
    (Config -> Config
concrete forall a b. (a -> b) -> a -> b
$ Config
Terminal.konnakolConfig { _terminalWidth :: Matra
Terminal._terminalWidth = Matra
width })

-- | 'Korvai.realizeScore' specialized to mridangam, and disbale the usual lint
-- and diff.
realizeScoreM :: (Terminal.Config -> Terminal.Config) -> Score -> IO ()
realizeScoreM :: (Config -> Config) -> Score -> IO ()
realizeScoreM Config -> Config
configure = (Korvai -> IO ()) -> Score -> IO ()
Korvai.realizeScore Korvai -> IO ()
realize
    where
    realize :: Korvai -> IO ()
realize = forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
Bool
-> Bool
-> Instrument stroke1
-> [Sequence]
-> Config
-> (Stroke stroke1 -> Maybe (Stroke stroke2))
-> Korvai
-> IO ()
Interactive.printInstrument Bool
False Bool
False Instrument Stroke
inst
        (forall stroke. Instrument stroke -> [Sequence]
_defaultStrokes Instrument Stroke
inst) (Config -> Config
configure Config
Terminal.defaultConfig)
        forall a. a -> Maybe a
Just
    inst :: Instrument Stroke
inst = Instrument Stroke
Korvai.IMridangam

-- | Like 'realize' but for Scores.
realizeScore :: Score -> IO ()
realizeScore :: Score -> IO ()
realizeScore = (Config -> Config) -> Score -> IO ()
realizeScoreM Config -> Config
concrete

_printInstrument
    :: (Solkattu.Notation stroke1, Solkattu.Notation stroke2, Ord stroke1)
    => (Realize.Stroke stroke1 -> Maybe (Realize.Stroke stroke2))
    -> Korvai.Instrument stroke1
    -> (Terminal.Config -> Terminal.Config)
    -> Korvai -> IO ()
_printInstrument :: forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
(Stroke stroke1 -> Maybe (Stroke stroke2))
-> Instrument stroke1 -> (Config -> Config) -> Korvai -> IO ()
_printInstrument Stroke stroke1 -> Maybe (Stroke stroke2)
postproc Instrument stroke1
inst Config -> Config
setConfig =
    forall stroke1 stroke2.
(Notation stroke1, Notation stroke2, Ord stroke1) =>
Bool
-> Bool
-> Instrument stroke1
-> [Sequence]
-> Config
-> (Stroke stroke1 -> Maybe (Stroke stroke2))
-> Korvai
-> IO ()
Interactive.printInstrument Bool
True Bool
True Instrument stroke1
inst (forall stroke. Instrument stroke -> [Sequence]
_defaultStrokes Instrument stroke1
inst)
        (Config -> Config
setConfig Config
Terminal.defaultConfig) Stroke stroke1 -> Maybe (Stroke stroke2)
postproc

-- * korvai

korvai :: Tala.Tala -> Korvai.StrokeMaps -> [Section] -> Korvai
korvai :: Tala -> StrokeMaps -> [Section] -> Korvai
korvai = Tala -> StrokeMaps -> [Section] -> Korvai
Korvai.korvai

korvai1 :: Tala.Tala -> Korvai.StrokeMaps -> Section -> Korvai
korvai1 :: Tala -> StrokeMaps -> Section -> Korvai
korvai1 Tala
tala StrokeMaps
smaps Section
section = Tala -> StrokeMaps -> [Section] -> Korvai
korvai Tala
tala StrokeMaps
smaps [Section
section]

korvaiS :: Tala.Tala -> Korvai.StrokeMaps -> [Sequence] -> Korvai
korvaiS :: Tala -> StrokeMaps -> [Sequence] -> Korvai
korvaiS Tala
tala StrokeMaps
smaps = Tala -> StrokeMaps -> [Section] -> Korvai
korvai Tala
tala StrokeMaps
smaps forall b c a. (b -> c) -> (a -> b) -> a -> c
 forall sollu. [SequenceT sollu] -> [Section (SequenceT sollu)]
Korvai.inferSections

korvaiS1 :: Tala.Tala -> Korvai.StrokeMaps -> Sequence -> Korvai
korvaiS1 :: Tala -> StrokeMaps -> Sequence -> Korvai
korvaiS1 Tala
tala StrokeMaps
smaps Sequence
seq = Tala -> StrokeMaps -> [Sequence] -> Korvai
korvaiS Tala
tala StrokeMaps
smaps [Sequence
seq]

-- TODO
-- vary :: Korvai -> Korvai
-- vary = Korvai.vary $ Solkattu.vary (Solkattu.variations [Solkattu.standard])