3      !"#$%&'()*+,-./012 Safe345F3-All recognized note alias in ascending order.45Modifiers specifying how to modulate some parameters. 356789:;<=>4 356789:;<=>4 356789:;<=>4Safe-/345F5Fundamental type representing an atom for evaluation.!Single value, evaluates to itself$Universal container for other values1Multivalue, the way to introduce varying elementsConditional multivalueOCollection of elements for evaluation, representation of some aspect of voice.??Safe345FkSyntactic element corresponds to language features. Some of them have direct corresponding constructor in  &, others have to be simplified first. Literal valueSection  Multivalue Conditional multivalue Reference (name of variable) Range of values Product of principlesDivision of principlesSum of principlesSubtraction of principlesLoopRotationReversed principleCSyntax tree in our case is just a collection of syntactic elements.     None345FUStatement can be either definition or exposition. Expositions are only used in REPL.CTest if given fragment of MIDA code is finished and self-contained.Entry point for MIDA parsing. Name of file Text to parse"Error message or parsed statements@ABCDEFGHIJKLMNOPQRSTUVWX@ABCDEFGHIJKLMNOPQRSTUVWXNone345F=Render a statement. This handles definitions and expositions.Render definition.Render syntax tree.Show principle. This is useful for printing of simplified principles back to user. We can use the same pretty-printing algorithm as for syntax trees, but this requires us to perform transformation from  to , which is trivial.YThis is used by $. It just creates lazy text builder.Z+Convert syntax tree into lazy text builder.[,Convert principle to syntax tree to show it.\1Pad given string with single space on both sides.Reference name Syntax tree$Textual representation of definitionYReference name Syntax tree%Lazy text builder for this definitionZ[\YZ[\None345CF>Type class for things that can be considered MIDA environment."Get collection of all definitions. #Update definitions with given ones.!Set random generator seed.">Split current random generator, update it, and return new one.#'Monad that implements MIDA environment.]qType synonym for collection of definitions, where a definition is a pair of variable name and corresponding AST.^iMIDA environment state. Basically this amounts to collection of definitions and random number generator._Collection of definitions`Random generator$&Run state monad with MIDA environment.a(Default definitions in MIDA environment.%(Add a new definition to the environment.&!Remove definition given its name.'?Remove all definitions, restoring default state of environment.(3Get principle corresponding to given variable name.)-Get source code of definition given its name.*5Reconstruct source code for all existing definitions.+.Get all reference names defined at the moment.bvThis performs definition traversal  and returns collection of definition names that given reference name depends on.,ePurge environment removing definitions that are not used in construction of top-level  definitions.-9Check if definition with given name is depends on itself.cJTurn collection of definition names into collection of empty definitions. !"#de]^f_`$a%Reference nameAST of its principle&Reference name'(Reference name Syntax tree)Reference name%Textual representation of source code*+bReference name DefinitionsCollection of definition names,Top-level definitions-Reference nameIts syntax treecghi !"#$%&'()*+,-# !"$%&'()*+,- !"#de]^f_`$a%&'()*+b,-cghiNone345Fj;State record used for calculation/evaluation of principles.kRecently evaluated valueslLocal random generator.#Evaluate definition given its name./Evaluate given syntax tree.m*Resolve principle into stream of naturals.nRun lazy state monad with j state.o$Random choice between given options.pCheck if given elements matches  history of generated values. This is for conditional multivalues, see manual for more information.=Note: head of history is the most recently evaluated element.qBConvert internals of conditional multivalue into plain multivalue.rA monadic wrapper around p.sAdd evaluated value to history.0 Transform  into B applying all necessary transformations and resolving references.t~Simplify section. There are several simple transformations that are proven to preserve the same resulting stream of naturals.u#Basic simplification of principles.vnSimplification of single element. Note that single element can produce several elements after simplification.w*The meat of the algorithm that transforms  into .xSaturated division.ySaturated subtraction.zConcept of looping.{Concept of rotation.|"Concept of reversion for elements.j}kl.Reference name)Infinite stream of naturals or empty list/ Syntax tree)Infinite stream of naturals or empty listmPrinciple in questionStream of naturalsn Monad to runInitial random generatorResultoOptions to choose fromResultp#History of already evaluated valuesElement to testDoes it match the history?qPattern/result pairsInternals of plain multivaluerStream of elements to testDo they match history?s0Syntax tree to transformResulting principletuvwSyntax tree to transformResulting principlexyz{|./0./0j}kl./mnopqrs0tuvwxyz{| None345F None345F(  !"#$%&'()*+,-./0( # !"$%&'()*+,-./0None345F+~.A synonym for what we use as track definition.Modulation figures.Static: no modulation#First ascending and then descending#First descending and then ascending Ascending for the whole duration!Descending for the whole durationMModulation parameters. This defines how sound will be modulated (if at all). Value or amplitude of modulationFigure or shape of modulationDuration in ticks Channel indexProducer function#Boundaries for ascending modulation$Boundaries for descending modulationI is collection of all parameters needed to generate complete MIDI track.Duration streamVelocity stream Pitch streamOptional modulation streamOptional breath streamOptional aftertouch streamOptional pitch bend stream'Apply transformation on all streams in .Default modulation parameters.4Default modulation parameters for breath modulation.8Default modulation parameters for aftertouch modulation.8Default modulation parameters for pitch bend modulation.1)Generate MIDI file from MIDA environment.$Generate MIDI track given its index.'Check if all necessary components in a  are defined.LTake some part (determined by number of ticks) of every infinite stream in  making it finite.Generate MIDI ~ from .(Merge several tracks together. There is  I thing, but I'm not sure it does it right, moreover it's not documented.Merge just two tracks.AGenerate track fragment representing modulation of one parameter.1Transform modulation parameters into fragment of ~.!Generate static stream of values.LGenerate up-down  or down-up  stream of values (i.e. returning stream ).!Generate linear stream of values.2Calculate one point from stream of integer values.2&Collection of top-level  definitions.Maximal voice index. 15( means that we can have 16 voices total.4~1Seed for random generator)Q value: number of ticks per quarter note#Duration in number of quarter notes MIDI file Track index for this trackRequested duration in ticks of infinite streams of finite streamsBatchChannel number Result track Raw modulation value, if present$Duration in ticks of entire fragment Channel indexDefault modulation parametersResult fragmentBeginning and end valuesAmplitude (from 0 to 127)Resulting streamBeginning and end values"Total number of elements in streamAmplitude (from 0 to 127)Resulting streamBeginning and end values"Total number of elements in streamAmplitude (from 0 to 127)Resulting streamBeginning and end values Numerator DenominatorValue of this point21212~12  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop0qkrstuvwxyz{|}~umida_4YR890Iw1OzCQhLy7nowqrMida.Language.ElementMida.Language.SyntaxTreeMida.Representation.ParserMida.Representation.ShowMida.Language.EnvironmentMida.Language.Eval Mida.MidiMida.Representation.BaseElementMida.Representation Mida.Language Codec.MidimergeValSecMulCMul PrincipleSelValueSectionMultiCMulti ReferenceRangeProductDivisionSumDiffLoopRotationReverse SyntaxTree Statement Definition Exposition probeMida parseMida showStatementshowDefinitionshowSyntaxTree showPrincipleHasEnvgetDefssetDefs setRandGen newRandGenMidaEnv runMidaEnvaddDefremDef clearDefsgetPringetSrcfullSrcgetRefspurgeEnv checkRecurevalDefevaltoPringenMiditopDefs noteAlias modifiers commentLine productOp divisionOpsumOpdiffOploopOp rotationOp reverseOprangeOpdefOp$fApplicativeElementpSource pDefinition pExposition pIdentifier pOperator pPrinciplepElementpRangepValuepNatural pReferencepSectionpMultipCMulti pExpressionoptTableanglesbracesbracketscommanaturalparenssymbollexemescshowDefinition'showSyntaxTree' toSyntaxTreepadDefs MidaEnvStmeDefs meRandGen defaultDefstDefstoDefs unMidaEnv$fHasEnvReaderT$fHasEnvStateT$fHasEnvMidaEnvCalcSt clHistory clRandGenresolverunCalcchoice condMatchtoMul matchHistory addHistory simplifySecsimplify simplifyElttoPrin'sdivsdiflooprotatereverse'TrackFigure FigStatic FigUpDown FigDownUpFigUpFigDown ModParamsmpValuempFigure mpDuration mpChannel mpProducer mpUpBounds mpDnBoundsBatchbtDurbtVelbtPch_btMod_btBth_btAft_btBndmodPbthPaftPbndPrequestdefinedslicetoTrack mixEventsmixPairfigurefigfigStcfigRtnfigLindrawmvIndexdefDurdefVeldefPchdefModdefBthdefAftdefBnd