alga-0.2.1: Algorithmic automation for various DAWs

Safe HaskellNone
LanguageHaskell2010

Alga.Language

Synopsis

Documentation

type SyntaxTree = [Sel] Source

Syntax tree in our case is just a collection of syntactic elements.

data Sel Source

Syntactic element corresponds to language features. Some of them have direct corresponding constructor in Element, others have to be simplified first.

Constructors

Value NRatio

Literal value

Section [Sel]

Section

Multi [Sel]

Multivalue

CMulti [([Sel], [Sel])]

Conditional multivalue

Reference String

Reference (name of variable)

Range NRatio NRatio

Range of values

Product Sel Sel

Product of principles

Division Sel Sel

Division of principles

Sum Sel Sel

Sum of principles

Diff Sel Sel

Subtraction of principles

Loop Sel Sel

Loop

Rotation Sel Sel

Rotation

Reverse Sel

Reversed principle

Instances

type Principle = [Element NRatio] Source

Collection of elements for evaluation, representation of some aspect of voice.

type NRatio = Ratio Natural Source

Non-negative rational number is the best choice for our purposes, hence the synonym.

data Element a Source

Fundamental type representing an atom for evaluation.

Constructors

Val a

Single value, evaluates to itself

Sec [Element a]

Universal container for other values

Mul [Element a]

Multivalue, the way to introduce varying elements

CMul [([Element a], [Element a])]

Conditional multivalue

class Monad m => HasEnv m where Source

Type class for things that can be considered ALGA environment.

Methods

getDefs :: m Defs Source

Get collection of all definitions.

setDefs :: Defs -> m () Source

Update definitions with given ones.

setRandGen :: Natural -> m () Source

Set random generator seed.

newRandGen :: m TFGen Source

Split current random generator, update it, and return new one.

Instances

runAlgaEnv :: Monad m => AlgaEnv m a -> m a Source

Run state monad with ALGA environment.

addDef Source

Arguments

:: HasEnv m 
=> String

Reference name

-> SyntaxTree

AST of its principle

-> m () 

Add a new definition to the environment.

remDef Source

Arguments

:: HasEnv m 
=> String

Reference name

-> m () 

Remove definition given its name.

clearDefs :: HasEnv m => m () Source

Remove all definitions, restoring default state of environment.

getPrin Source

Arguments

:: HasEnv m 
=> String

Reference name

-> m SyntaxTree

Syntax tree

Get principle corresponding to given variable name.

getSrc Source

Arguments

:: HasEnv m 
=> String

Reference name

-> m Text

Textual representation of source code

Get source code of definition given its name.

fullSrc :: HasEnv m => m Text Source

Reconstruct source code for all existing definitions.

getRefs :: HasEnv m => m [String] Source

Get all reference names defined at the moment.

purgeEnv Source

Arguments

:: HasEnv m 
=> [String]

Top-level definitions

-> m () 

Purge environment removing definitions that are not used in construction of “top-level” definitions.

checkRecur Source

Arguments

:: HasEnv m 
=> String

Reference name

-> SyntaxTree

Its syntax tree

-> m Bool 

Check if definition with given name is depends on itself.

evalDef Source

Arguments

:: HasEnv m 
=> String

Reference name

-> m [NRatio]

Infinite stream of naturals or empty list

Evaluate definition given its name.

eval Source

Arguments

:: HasEnv m 
=> SyntaxTree

Syntax tree

-> m [NRatio]

Infinite stream of ratios or empty list

Evaluate given syntax tree.

toPrin Source

Arguments

:: HasEnv m 
=> SyntaxTree

Syntax tree to transform

-> m Principle

Resulting principle

Transform SyntaxTree into Principle applying all necessary transformations and resolving references.