AlgoRhythm-0.1.0.0: Algorithmic music composition

Safe HaskellNone
LanguageHaskell2010

Grammar.Types

Synopsis

Documentation

data Grammar meta a Source #

Constructors

Grammar 

Fields

data Rule meta a Source #

Constructors

(Head a) :-> (Body meta a) infix 3 

type Head a = (a, Weight, Activation) Source #

type Body meta a = Duration -> Term meta a Source #

data Term meta a Source #

Constructors

a :%: Duration infix 6 
(Term meta a) :-: (Term meta a) infixr 4 
Aux Bool meta (Term meta a) 
Let (Term meta a) (Term meta a -> Term meta a) 

Instances

Functor (Term meta) Source # 

Methods

fmap :: (a -> b) -> Term meta a -> Term meta b #

(<$) :: a -> Term meta b -> Term meta a #

(Eq a, Eq meta) => Eq (Term meta a) Source # 

Methods

(==) :: Term meta a -> Term meta a -> Bool #

(/=) :: Term meta a -> Term meta a -> Bool #

(Show a, Show meta) => Show (Term meta a) Source # 

Methods

showsPrec :: Int -> Term meta a -> ShowS #

show :: Term meta a -> String #

showList :: [Term meta a] -> ShowS #

class Expand input a meta b | input a meta -> b where Source #

Any metadata-carrying grammar term must be expanded to a stripped-down grammar term with no metadata (i.e. `Term a ()`), possibly producing terms of a different type b.

Minimal complete definition

expand

Methods

expand :: input -> Term meta a -> IO (Term () b) Source #

Expand meta-information.

Instances

Expand input a () a Source #

A term with no auxiliary wrappers can be trivially expanded.

Methods

expand :: input -> Term () a -> IO (Term () a) Source #

Expand HarmonyConfig Degree Modulation SemiChord Source #

Expands modulations and intreprets degrees to chords.

type Grammarly input a meta b = (Show a, Show meta, Eq a, Eq meta, Expand input a meta b) Source #

runGrammar :: Grammarly input a meta b => Grammar meta a -> Duration -> input -> IO (Music b) Source #

Run a grammar with the given initial symbol.

always :: Activation Source #

Rule which always activates.

(/\) :: Activation -> Activation -> Activation Source #

Conjunction of activation functions.

(\/) :: Activation -> Activation -> Activation Source #

Disjunction of activation functions.

(|:) :: a -> [Rule meta a] -> Grammar meta a infix 2 Source #

(-|) :: a -> Weight -> Rule meta a Source #

Identity rule.

(-||) :: (a, Weight) -> Activation -> Rule meta a Source #

Identity rule with activation function.

($:) :: meta -> Term meta a -> Term meta a infix 5 Source #

Operators for auxiliary terms.

(|$:) :: meta -> Term meta a -> Term meta a infix 5 Source #

Operators for auxiliary terms.

(|->) :: Head a -> Term meta a -> Rule meta a infix 3 Source #

Rule with duration-independent body.