| Safe Haskell | Safe-Inferred |
|---|
Derive.Parse.Instruments
Contents
Description
Parsing support for the "instrument:" section of the ky file.
This is an awkward hybrid. Firstly, the name is inconsistent, internally
they are called "allocation" because "instrument" usually corresponds to
ScoreT.Instrument, while the allocation is the thing tying instrument
to patch. But at the UI level I find "allocation" too vague and use
"instrument" for both concepts.
But the main thing is that Allocation corresponds only to a subset of
the actual Allocation. The real source of truth is
UiConfig.Allocation. So the ky equivalent has to merge in any changes
that may have happened to the config (done in Parse.Ky.merge_instruments),
which means automatically updating source, which is fiddly as usual.
A more traditional and simpler way would be to make the ky source be the source of truth, but that would mean having it serialize all the fields. I got pretty far down this route, but it got pretty complicated because there's a whole new expression language and serialization layer, and I become unsure if it was really a good idea.
So we do complicated merging for now.
Synopsis
- data Allocation = Allocation {}
- data Config = Config {
- config_mute :: !Bool
- config_solo :: !Bool
- empty_config :: Config
- data Backend
- from_ui :: ScoreT.Instrument -> UiConfig.Allocation -> Either Error Allocation
- instrument_section :: Text
- update_ui :: LookupBackend -> [Allocation] -> UiConfig.Allocations -> Either Error UiConfig.Allocations
- p_allocation :: Parser Allocation
- unparse_allocations :: [(Maybe Allocation, Comment)] -> [Text]
- spaces :: Parser ()
Documentation
data Allocation Source #
This is a simplified subset of Allocation.
Constructors
| Allocation | |
Fields | |
Instances
| Show Allocation Source # | |
Defined in Derive.Parse.Instruments Methods showsPrec :: Int -> Allocation -> ShowS # show :: Allocation -> String # showList :: [Allocation] -> ShowS # | |
| Eq Allocation Source # | |
Defined in Derive.Parse.Instruments | |
Subset of Config.
Constructors
| Config | |
Fields
| |
Constructors
| Midi Midi.WriteDevice [Midi.Channel] | |
| NonMidi |
Instances
from_ui :: ScoreT.Instrument -> UiConfig.Allocation -> Either Error Allocation Source #
update_ui :: LookupBackend -> [Allocation] -> UiConfig.Allocations -> Either Error UiConfig.Allocations Source #
Merge the Allocations parsed from the instrument section into the Ui level config.
parse
p_allocation :: Parser Allocation Source #
unparse_allocations :: [(Maybe Allocation, Comment)] -> [Text] Source #